Passing values to a JSP file

Help!
This is a very trivial and simple problem but stupid me couldn't figure out. I am developing a web interface with a database. I retrieved some records with a recordset. Now I am passing the id value to the next jsp file. This is what my code looks like:
<td>
<a href="someDetail.jsp?id= + ""<%= results.getString("id") %">""><%= results.getString("name") %>
</a>
</td>
Once the screen comes up with all the records and when I click one particular record it goes to the someDetail.jsp file but it is not taking the id with it. In the someDetail.jsp screen the URL looks like this.
http://localhost/someData/someDetail.jsp?id=
What am I missing here?
Sue

<a href="someDetail.jsp?id= + ""<%=
results.getString("id") %>""><%=
results.getString("name") %>Why not just assign a variable to the id? ie.
<% while (results.next()) {
String someId = results.getString("id");
%>
<td><a href="someDetail.jsp?id=<%=someId%>">Detail Page</a></td>
<% } %>
Hope this helps a bit.

Similar Messages

  • How to pass value from the jsp file to a java bean

    I have huge promblem .I want to pass value of combo box to bean file to set my database contecting.The is how i call function to pass database to the bean file
    <%db.setDatabase(database);%>are coding to set my databse connection
    private String database;
        public Conn(){
         try{
                   Class.forName("org.gjt.mm.mysql.Driver");
                   DriverManager.registerDriver((Driver) Class.forName("org.gjt.mm.mysql.Driver").newInstance());
                   String data=getDatabase();
                   String url = "jdbc:mysql://localhost/"+data;
                   Connection conn = DriverManager.getConnection(url);
                   setConnection(conn);
              catch(SQLException e){
                   System.out.println(e.toString());
              catch(Exception e){
                   System.out.println(e.toString());
         public void setDatabase(String Database){
          this.database = Database;
         public String getDatabase(){
         return this.database;
         }     and Below are error produce
    Note: sun.tools.javac.Main has been deprecated.
    /mrs/system_menu.jsp:18: Method setDatabase(java.lang.String) not found
    in class bgoc.dbConn.Conn.
    db.setDatabase(database);
    ^
    1 error, 1 warning
    please help me soon. any that come to your will help
    thank you

    I have huge promblem .I want to pass value of combo box to bean file to set my database contecting.The is how i call function to pass database to the bean file
    <%db.setDatabase(database);%>are coding to set my databse connection
    private String database;
        public Conn(){
         try{
                   Class.forName("org.gjt.mm.mysql.Driver");
                   DriverManager.registerDriver((Driver) Class.forName("org.gjt.mm.mysql.Driver").newInstance());
                   String data=getDatabase();
                   String url = "jdbc:mysql://localhost/"+data;
                   Connection conn = DriverManager.getConnection(url);
                   setConnection(conn);
              catch(SQLException e){
                   System.out.println(e.toString());
              catch(Exception e){
                   System.out.println(e.toString());
         public void setDatabase(String Database){
          this.database = Database;
         public String getDatabase(){
         return this.database;
         }     and Below are error produce
    Note: sun.tools.javac.Main has been deprecated.
    /mrs/system_menu.jsp:18: Method setDatabase(java.lang.String) not found
    in class bgoc.dbConn.Conn.
    db.setDatabase(database);
    ^
    1 error, 1 warning
    please help me soon. any that come to your will help
    thank you

  • How to get the weblogic.httpd.session.timeoutSecs value in a JSP file

    Hi,
              We are using Weblogic 5.1 SP8. We set weblogic.httpd.session.timeoutSecs=900 in the weblogic.properties file. How can I get this value in a JSP file if I don't use java.util.Properties to parse the properties file?
              Can I use session.getValue(sessionName) to get it? If so, what is the session name for this property?
              Thanks.
              Frank
              

    I think something like this should work:
              T3ServicesDef services = T3Services.getT3Services();
                   services.config().getProperty("weblogic.httpd.session.timeoutSecs");
              Frank Yu <[email protected]> wrote:
              > Hi,
              > We are using Weblogic 5.1 SP8. We set weblogic.httpd.session.timeoutSecs=900 in the weblogic.properties file. How can I get this value in a JSP file if I don't use java.util.Properties to parse the properties file?
              > Can I use session.getValue(sessionName) to get it? If so, what is the session name for this property?
              > Thanks.
              > Frank
              Dimitri
              

  • Passing value from one jsp to another?

    how to pass value from one jsp to another? i have a value assigned in the link, i want to pass that value to another jsp page?
    please help with code?

    Instead of the value being passed, i am getting a null value.
    Here is my calendar code:
    <%@page import="java.util.*,java.text.*" %>
    <html>
    <head>
    <title>Print a month page.</title>
    </head>
    <body bgcolor="white">
    <%
                  boolean yyok = false;
                  int yy = 0, mm = 0;
                  String yyString = request.getParameter("year");
                  if (yyString != null && yyString.length() > 0)
                      try
                          yy = Integer.parseInt(yyString);
                                  yyok = true;
                       catch (NumberFormatException e)
                          out.println("Year " + yyString + " invalid" );
                  Calendar c = Calendar.getInstance( );
                  if (!yyok)yy = c.get(Calendar.YEAR);  
                         mm = c.get(Calendar.MONTH);
    %>
                  <table align="center">
                      <tr>
                  <td>
                       <form method=post action="calendar.jsp">
                          Enter Year : <select name="year">
    <%         
                 for(int i= yy;i<=2010;i++)
    %>
                  <OPTION VALUE= <%=i%> > <%=i%> </option>
    <%       
    %>
              </select>
                      <input type=submit value="Display">
                      </form>
                      </td>
                    </tr>
    <tr>
                     <table>
    <%!
    String[] months = {"January","February","March",
                    "April","May","June",
                    "July","August","September",
                    "October","November", "December"
    int dom[] =     {
                        31, 28, 31, 30,
                        31, 30, 31, 31,
                        30, 31, 30, 31
    %>
    <%
                int leadGap =0;
    %>
    <div id="t1" class="tip"><table border="4" cellpadding=3 cellspacing="3" width="250" align="center" bgcolor="lavender">
    <tr>
    <td halign="centre" colgroup span="7" style="color:#FF0000;">
    </colgroup>
    <tr>
    <td>
    <%
              GregorianCalendar calendar =null;
              for(int j=0;j<12;j++)
                        calendar = new GregorianCalendar(yy, j, 1);
                  int row = 1 ;
                  row = row + j;
        %>
              <table>
                <tr>
              <colgroup span="7" style="color:#FF0000;">
              </colgroup>
                </tr>
              <tr align="center">
              <th colspan=7>
                  <%= months[j] %>
                  <%= yy %>
              </th>
              </tr>
    <tr>
    <td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td>
    </tr>
    <%
        leadGap = calendar.get(Calendar.DAY_OF_WEEK)-1;
        int daysInMonth = dom[j];
        if ( calendar.isLeapYear( calendar.get(Calendar.YEAR) ) && j == 1)
        ++daysInMonth;
        out.print("<tr>");
        out.print(" ");
          for (int h = 0; h < leadGap; h++)
           out.print("<td>");
          out.print("</td>");
        for (int h = 1; h <= daysInMonth; h++)
          out.print("<td>");
          out.print("<a href=desc.jsp>" + h + "</a>" );
          out.print("</td>");
        if ((leadGap + h) % 7 == 0)
            out.println("</tr>");
    out.println("</tr></table></div>");
    if( row%3 != 0)
    out.println("</td><td>");
    else
    out.println("</td></tr>\n<tr><td>");
    %>
    </html>I need to pass the value in 'h' to the desc.jsp page.
    my code for desc.jsp is :
    <html>
    <head>
    </head>
    <body bgcolor="lightblue">
    <form method=post action="Calenda.jsp">
    <br>
    <%= request.getParameter("h") %>
    <h2> Description of the event <INPUT NAME="description" TYPE=TEXT SIZE=20> </h2>
    <BR> <INPUT TYPE=SUBMIT VALUE="submit">
    </form>
    </body>
    </html>But i am not able to pass the value. The 'h' value contains all the date. i want to pass only a single date, the user clicks to the other page. please help

  • Passing parameters to included JSP files using JSF

    I have included JSP, which I use in many other JSP files. I want to display message in this included JSP which depends on the information in JSP files which include this JSP. How can I do this without using scriptlets?
    Message was edited by:
    cheltsov

    I have one included page in one jsp page(mother page). I have included it by jsp:include tag. The included page consists of two inputText. I need to pass the parameters of the mother page together with the parameters in the included page in the backingBean of the mother page. Hope this one is clearer.
    The code snippet in the mother page looks like this
    <jsp:include page="/pages/ps/sample_rep2.jsp"/>.
    In the sample_rep2.jsp, I have two inputText. How can I pass this in the backingBean of the motherpage.
    The sample_rep2.jsp is the included page here. The sample_rep2.jsp looks like this:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
    <af:panelBox>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
    <af:panelBox>
    <af:inputText label="User ID" id="userid" value="CDOUGLAS"/>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
    <af:panelBox>
    <af:inputText label="User ID" id="userid" />
    <af:inputText label="Age" id="age"/>
    </af:panelBox>

  • Passing values from a jsp to a servlet

    I have a jsp which has a search form for customers, first it lets you search by colour, giving options of red, white or all, then gives three options of what price. Im trying to get my servlet to read these choices, and display the results. I have a statement in my serlvet which says:
    String price = request.getParameter("search preference colour");
    and the statment in the JSP is:
    <select name="search preference colour">
    <option value="Red">red</option>
    <option value="White">White</option>
    <option value="All">All</option>
    </select>
    I need to know how to define which option has been chosen, and have the chosen results displayed. I tried an 'if' statement but it didnt seem to work. Thanks

    yuvi wrote:
    i have a servlet from which i am passing result set values to a jsp page.Basically they are database records from a table named basic.
    and these selective fields have to be dissplayed on jsp.i have tried incorporating values into session variables and using them on jsp.it works fine for single record but when there are multiple results it fails!! :(Learn JSTL and use tags. Scriptlet code in JSPs is a bad idea.
    %

  • Passing values to a JSP script from an Applet

    I am having problems to passing arguments to a JSP scipt.
    In the applet the following code is executed:
    URL scoreTrackerURL = new URL(applet.getCodeBase(), "newscore.jsp?name=foo&score=10000");
    URLConnection scoreTrackerConn = scoreTrackerURL.openConnection();
    scoreTrackerConn.connect();
    The JSP-script in the newscore.jsp looks like this:
    <%@ page language="java" %>
    <%@ page import="java.util.*" %>
    <%@ page import="java.net.*" %>
    <%@ page import="java.io.*" %>
    <%
    String name = request.getParameter("name");
    String score = request.getParameter("score");
    BufferedWriter writer = new BufferedWriter(new FileWriter("highscore.txt"));
    writer.write(name + ", " + score);
    writer.close();
    %>
    What am I doing wrong since this doesn�t work!!! I have very little experience of JSP and accessing these scipts from Applets...
    Dukecredits are waiting for You! :) Thank you!

    I tried your code and it works fine.
    public class AppletParam extends Applet {
        public void paint(Graphics g) {
         g.setColor(Color.red);
         g.fillRect(0,0, getSize().width, getSize().height);
         try {
             URL scoreTrackerURL = new URL(getCodeBase(), "newscore.jsp?name=foo&score=10000");
             System.out.println(scoreTrackerURL);
             URLConnection scoreTrackerConn = scoreTrackerURL.openConnection();
             scoreTrackerConn.connect();
         } catch(IOException ioe) {
             ioe.printStackTrace();
    }The call to System.out.println writes the URL that's to be called to the java console in the webbrowser, so you can verify that the method has been called.Any Exceptions that might occour within the method will show up in the same place
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>New Score</title>
      </head>
      <body>
        <h1>New Score</h1>
    <%@ page language="java" %>
    <%@ page import="java.util.*" %>
    <%@ page import="java.net.*" %>
    <%@ page import="java.io.*" %>
    <%
    String name = request.getParameter("name");
    String score = request.getParameter("score");
    System.out.println("name=" + name + " score=" + score);
    BufferedWriter writer = new BufferedWriter(new FileWriter("highscore.txt"));
    writer.write(name + ", " + score);
    writer.close();
    %>
      </body>
    </html>Again a call to System.out.println . This time it results in the two parameters being written to the application server log file, so you can see if the jsp was called and what the parameters were.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>test af AppletParam</title>
      </head>
      <body>
        <h1>test af AppletParam</h1>
        <applet codebase="." code="kres_test.AppletParam" width=200 height=200>
        </applet>
      </body>
    </html>The html file with the applet. Remember to place the class file in the correct place. If not you will get an error message in the java console of the webbrowser.
    My tests was performed on a WebLogic 6.1 application server, but there's nothing special about your code, it ought to run on any decent J2EE application server.

  • How to pass value to a control file in sql loader

    Hello
    please want to know if i can pass a value to a control file?
    I have a table which i will populate using a control file but there is a field in the table which i will pass the date of the file.
    how can i archive this
    Thanks
    Edited by: kama021 on Apr 18, 2012 3:49 AM

    The content of the control file must be made dynamically to include desired value.
    Handle:     kama021
    Status Level:     Newbie
    Registered:     Jun 9, 2009
    Total Posts:     154
    Total Questions:     42 (25 unresolved)
    Why so many unanswered questions?
    Edited by: sb92075 on Apr 18, 2012 6:34 AM

  • Passing values to the JSP page - Urgent

    Hi all,
    I have to pass the user id value to the JSP page. I have written the following code in the doInitialization() method
    IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
    IPortalComponentContext myContext = request.getComponentContext();
    IPortalComponentProfile myProfile = myContext.getProfile();
    IAuthentication ia = UMFactory.getAuthenticator();
    IUser portalUser = ia.getLoggedInUser(request.getServletRequest(), request.getServletResponse(false) );
    s = portalUser.getUniqueName();
    IPortalComponentSession componentSession = ((IPortalComponentRequest)getRequest()).getComponentSession();
    Object o = componentSession.getValue("myEvents");
    myEvents = (LoadEvents)o;
    //myEvents = (LoadEvents) myContext.getValue("myEvents");
    myEvents.setUserId(s);
    myContext.putValue("myBeanName", myEvents);
    I have also defined myEvents as a bean in my JSP page with scope APPLICATION. But I get User Id as "NULL".
    Thanks in advance.
    Rgds,
    Janvi.

    Hi Prakash,
    Please find the jsp code pasted below:
    <hbj:content
        id="myContext">
        <hbj:page
            title="Successful processing">
    <jsp:useBean id="myMeet" scope="application" class="com.sap.ep.bluestar.LoadEvents" />
    <jsp:useBean id="myEvents" class="com.sap.ep.bluestar.MonthView" scope="application" />
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" %>
    <%
    int leadSpaces, daysInMonth, leadSpaces_next,daysInMonth_next, col_Counter;
    myCal.setMonthView();
    java.util.Vector printVal_pre = new java.util.Vector();
    myCal.printMonth(myCal.getPre_month(),myCal.getPre_year());
    printVal_pre = myCal.getPrintValues();
    java.util.Vector printVal_cur = new java.util.Vector();
    myCal.printMonth(myCal.getCur_month(),myCal.getCur_year());
    printVal_cur = myCal.getPrintValues();
    java.util.Vector printVal_next = new java.util.Vector();
    myCal.printMonth(myCal.getNext_month(),myCal.getNext_year());
    printVal_next = myCal.getPrintValues();
    if(request.getMethod().equals("POST")){
         try {
              String action =(String) request.getParameter("action");
              if(action.equals("insert")){
              //     response.sendRedirect("_insertEvent.jsp");
                   //response.sendRedirect("test.html");
         } catch(Exception e) {
              System.out.println(e.getMessage());
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <script language="javascript">
         function insertEvent(frm,eventDay){
              alert("here finally " + eventDay + " " + frm.eventMonth.value + "  " + frm.eventYear.value );
              frm.action.value = "insert";
              frm.submit();
         function openWin(frm,eventDay)
           var newWin = window.open("http://localhost:50100/irj/servlet/prt/portal/prtroot/Web_Calendar.eventHandler?variable=" + frm.eventMonth.value +  "/" + eventDay + "/" + frm.eventYear.value, 'popup',
         'resizable,height=200,width=325');
           if(newWin.focus) newWin.focus();
    </script>
    </head>
    <body>
    User is : <%= myCal.getUserId() %>
    <table width="745" height="583" border="0">
      <tr>
        <td width="258" height="23" align="center"><B> <% out.println(printVal_pre.elementAt(0).toString() + "  " + printVal_pre.elementAt(1).toString());
    leadSpaces = ((Integer)printVal_pre.elementAt(2)).intValue();
         daysInMonth = ((Integer)printVal_pre.elementAt(3)).intValue();
         %> </B> </td>
        <td width="215"> </td>
        <td width="258" align="center"><B> <% out.println(printVal_next.elementAt(0).toString() + "  " + printVal_next.elementAt(1).toString());
        leadSpaces_next = ((Integer)printVal_next.elementAt(2)).intValue();
        daysInMonth_next = ((Integer)printVal_next.elementAt(3)).intValue();
         %> </B></td>
      </tr>
      <tr>
        <td height="151"><table width="245" border="1">
          <tr>
            <th width="35" scope="col"><div align="center">S</div></th>
            <th width="35" scope="col"><div align="center">M</div></th>
            <th width="35" scope="col"><div align="center">T</div></th>
            <th width="35" scope="col"><div align="center">W</div></th>
            <th width="35" scope="col"><div align="center">T</div></th>
            <th width="35" scope="col"><div align="center">F</div></th>
            <th width="35" scope="col"><div align="center">S</div></th>
          </tr><tr>
         <% col_Counter = 0;
              for (int i = 0; i < leadSpaces; i++) {
                   out.print("<td> </td>");
                   col_Counter++;
              for (int i = 1; i <= daysInMonth; i++) {
                   // This "if" statement is simpler than messing with NumberFormat
                   if(i < 9) {
                        out.print("<td align='center'>" + " " + i + "</td>");
                        col_Counter++;
                   } else {
                        out.print("<td align='center'>" + i + "</td>");
                        col_Counter++;
                   if ((leadSpaces + i) % 7 == 0) { // Wrap if EOL
                        out.println("</tr><tr>");
              int cnt = col_Counter;
              if(col_Counter == 28){
                   out.println("</tr>");
              }else {
                   for(int i = 0; i < (42 - col_Counter);i++){
                        out.print("<td> </td>");
                        cnt++;
                        if((cnt%7) ==0)
                             out.println("</tr><tr>");
                   out.println("</tr>");
         %>
        </table></td>
        <td> </td>
        <td><table width="245" border="1">
          <tr>
            <th width="35" scope="col"><div align="center">S</div></th>
            <th width="35" scope="col"><div align="center">M</div></th>
            <th width="35" scope="col"><div align="center">T</div></th>
            <th width="35" scope="col"><div align="center">W</div></th>
            <th width="35" scope="col"><div align="center">T</div></th>
            <th width="35" scope="col"><div align="center">F</div></th>
            <th width="35" scope="col"><div align="center">S</div></th>
          </tr>
          <tr>
           <% col_Counter = 0;
              for (int i = 0; i < leadSpaces_next; i++) {
                   out.print("<td> </td>");
                   col_Counter++;
              for (int i = 1; i <= daysInMonth_next; i++) {
                   // This "if" statement is simpler than messing with NumberFormat
                   if(i < 9) {
                        out.print("<td align='center'>" + " " + i + "</td>");
                        col_Counter++;
                   } else {
                        out.print("<td align='center'>" + i + "</td>");
                        col_Counter++;
                   if ((leadSpaces_next + i) % 7 == 0) { // Wrap if EOL
                        out.println("</tr><tr>");
              cnt = col_Counter;
              if(col_Counter == 28){
                   out.println("</tr>");
              }else {
                   for(int i = 0; i < (42 - col_Counter);i++){
                        out.print("<td> </td>");
                        cnt++;
                        if((cnt % 7 ) ==0)
                        out.println("</tr><tr>");
                   out.println("</tr>");
         %>
        </table></td>
      </tr>
      <tr>
        <td colspan="3"><table width="735" height="383" border="1">
          <tr>
          <td colspan="7" align="center"><B> <% out.println(printVal_cur.elementAt(0).toString() + "  " + printVal_cur.elementAt(1).toString());
        leadSpaces = ((Integer)printVal_cur.elementAt(2)).intValue();
        daysInMonth = ((Integer)printVal_cur.elementAt(3)).intValue();
         %> </B></td>
          </tr>
          <tr>
            <th width="105" scope="col">SUN</th>
            <th width="105" scope="col">MON</th>
            <th width="105" scope="col">TUE</th>
            <th width="105" scope="col">WED</th>
            <th width="105" scope="col">THUR</th>
            <th width="105" scope="col">FRI</th>
            <th width="105" scope="col">SAT</th>
          </tr>
          <form name="eventCal" method="post" action="Web_Cal.jsp">
          <input name="eventMonth" type="hidden" value="<%= myCal.getCur_month() + 1 %>">
           <input name="eventYear" type="hidden" value="<%=myCal.getCur_year() %>">
          <input name="action" type="hidden" value="">
          <tr>
            <% col_Counter = 0;
              for (int i = 0; i < leadSpaces; i++) {
                   out.print("<td> </td>");
                   col_Counter++;
              for (int i = 1; i <= daysInMonth; i++) {
                   // This "if" statement is simpler than messing with NumberFormat
                   if(i < 9) {
                        out.print("<td align='center'>" + " " + "<a href='javascript:openWin(document.eventCal," + i + ");'>" + i + "</a></td>");
                        col_Counter++;
                   } else {
                        out.print("<td align='center'>" + "<a href='javascript:openWin(document.eventCal," + i + ");'>" + i + "</a></td>");
                        col_Counter++;
                   if ((leadSpaces + i) % 7 == 0) { // Wrap if EOL
                        out.println("</tr><tr>");
              if(col_Counter == 28){
                   out.println("</tr>");
              }else if(col_Counter < 35){     
                   for(int i = 0; i < (35 - col_Counter);i++)
                        out.print("<td> </td>");
                   out.println("</tr>");
              }else {
                   for(int i = 0; i < (42 - col_Counter);i++)
                        out.print("<td> </td>");
                   out.println("</tr>");
         %> </form>
        </table></td>
      </tr>
    </table>
    </body>
    </html>
    </hbj:textView>
        </hbj:page>
    </hbj:content>
    Regards,
    Janvi

  • Open a web page and pass values from a java file

    Hi,
    I need to open a web page and pass values in the text boxes.
    Finally submit needs to be triggered. All this needs to be done from a java file. i.e instead of entering my values in a web page and submit, i need to do it from my java file..
    Any inputs so that I proceed in the right direction..or is there any alternate way to achive this ??
    Thanks in advance..
    Sid

    I hava found a lines of jaa that can open a URL , lets say www.net.java
    You can open it writable or not.
    It is half of the job you need.
    If you are interested.
    I am wrinting a program to print a URL , and have developed this small
    code.
    Angel Portal

  • Passing values to included jsp via bean

    Hi people
    I've got a jsp fragment which is used by many jsp's. It outputs a dynamic menu. It gets its data from a bean, say MenuBean. The jsp which "includes" menu.jsp does a jsp:usebean then jsp:setproperty's on MenuBean. When I run the project nothing comes up in the menu (It works if I hardcode the values in MenuBean).
    Under debug I can see that after the first jsp:usebean an instance (say #9360) is created with the properties set correctly. But when menu.jsp runs, it looks like a new instance of MenuBean (say #110636) is created with the properties blank.
    in home.jsp:
    <jsp:useBean id="menubean" class="web.MenuBean" scope="session"/>
    <jsp:setProperty name="menubean" property="login"
    value="${userBean.login}"/>
    <jsp:setProperty name="menubean" property="topLevel" value="Home"/>
    <jsp:include page="/WEB-INF/jspf/menu.jsp" />
    in menu.jsp:
    <jsp:useBean id="menubean" class="web.MenuBean" scope="session"/>
    I've tried changing the scope to request or application, but it's always the same result. A new instance of MenuBean is created when menu.jsp runs. What I need is a single instance of MenuBean running throughout the session and accessible by every jsp that's called up. How can I do/achieve this?
    I'd appreciate any help on this matter.
    Thanks.

    Hi Ram - thanks for your reply.
    I have made it work, but I'm not sure which of the changes I made is the one that fixed it. I believe it is because I didn't implement serializable in my MenuBean. By doing so it now works!!
    thankyou & bye

  • Passing values from a JSP to Action class

    Hi,
    I have one JSP in this I have two select boxes.
    The first select box is populated with default values.
    From the first select box I am selecting the value and moving to the other select box using java script.
    Now the value in the second select box has to be submitted alongwith some other values which I am getting.
    These values are to be submitted to a Action class and further to the form bean using struts.
    In the form tag in JSP I am calling the struts action class.
    The issue here is,I am able to get other values except the values in the second select box.
    I am using simple JSP page to get form values and submitting.
    I am not using struts tlds because of project constraints.
    Please advise on how to pass these values.
    Regards,
    Ram

    If the value from the select box isn't submitted, then it's not inside the form. Check the HTML output of your JSP to debug this problem.

  • Passing values in a jsp

    I am sending 2 values to the next jsp page from a current jsp page. Am using a form like this
    <form name=report method=get action=./modules/pccr/pccr_assignedengineer_report.jsp target=assignedengineer_report>
    These are the 2 values
    <select name="assignedbu" >
    <td><select name="assignedeng">
    The assignedbu stores a String with a space between the words. When the jsp gets the values its only getting the first word. For example if
    assignedbu = Hello Servlet World; in the original jsp. The next jsp only recieves "Hello". Can anyone tell me how to resolve this..... ?
    Thanks

    sure, i tried passing the string value assignedbu thru
    onClick ="PrintReport(<%=assignedbu)"> all the way in the end, but its giving me some error
    <%@ page import="java.util.*" %>
    <%@ page import="javax.swing.*" %>
    <%
    String assignedbu = "";
    String engineer = request.getParameter("assignedeng");
    assignedbu = request.getParameter("assignedbu");
    try
         if ( assignedbu.equals(null) )
              assignedbu ="";
    catch ( Exception e)
         assignedbu = "";
    JOptionPane.showMessageDialog(null, "BU : " + assignedbu);
    //String bu = request.getParameter("assignedbu");
    %>
    <script>
    function EngList() {
              var assignedbus = document.report.assignedbu.value;
              //     alert ( 'assignedbus : ' + assignedbus )
    window.location ='index.jsp?module=pccr&func=assignedengineer_prereport&assignedbu='+ assignedbus
    function PrintReport() {
         var assignedbus = document.report.assignedbu.value;
         alert ( 'assignedbus : ' + assignedbus )
         window.location ='index.jsp?module=pccr&func=assignedengineer_report&assignedbu=' + assignedbus
    function Refresh()
         window.location ='index.jsp?module=pccr&func=assignedengineer_prereport&assignedbu='
    </script>
    <br>
    <font FACE="VERDANA,ARIAL">Open PCCR/DCR for an Assigned Engineer</font>
    <form name=report method=get action=./modules/pccr/pccr_assignedengineer_report.jsp target=assignedengineer_report>
    <TABLE border=0 cellpadding=0 width=90%>
    <tr>
         <td colspan=20><font FACE="VERDANA,ARIAL" size=2>Select Assigned Business Unit: </font></td>
         <%
         JOptionPane.showMessageDialog(null, "BU : " + assignedbu);
         Context context = MatrixContext.setContext();
         if ( assignedbu.equals("") )
              { %>
         <td><select name="assignedbu" onClick = "EngList()">
         <%
              //JOptionPane.showMessageDialog(null, "assignedbu : in else1 " );
              AttributeType attType = new AttributeType("ASSIGNED BUSINESS UNIT");
              attType.open(context);
              StringList strlist = attType.getChoices();
              strlist.sort();
              for (int i=0; i < strlist.size(); i++)
                   out.println("<option VALUE=\"" + strlist.get(i) + "\" >" + strlist.get(i) );
              attType.close(context);
                   %>      </select></td>
              <% }
              else
                   //JOptionPane.showMessageDialog(null, "in else" );
         %>
              <!-- <td><option value= "assignedbu" > <%=assignedbu%>     </td>     -->
              <td><select name="assignedbu" >
                        <option value= <%=assignedbu%> > <%=assignedbu%> </select>     </td>     
              <%} %>
         <td></td>
         <td colspan=2>
         <input type=button method = post value="Change Business Unit" onclick = "Refresh()">
         </td>
         </tr><tr></tr><tr></tr><tr></tr><tr></tr>
         <tr>
         <td colspan=20><font FACE="VERDANA,ARIAL" size=2>Select Assigned Engineer: </font></td>
         <td><select name="assignedeng">
         <%
         //     JOptionPane.showMessageDialog(null, "BU : " + assignedbu);
              if ( !assignedbu.equals("") )
                   BUReport.assignedbu = assignedbu;
                   PccrRanges pccrRanges = new PccrRanges( context, assignedbu);     
                   ArrayList engineersList = pccrRanges.AssignedEngineers;
                   Object [] obj = engineersList.toArray();
                   Arrays.sort(obj);
                   for (int k=0; k < obj.length; k++)
                        out.println("<option VALUE=\"" + obj[k].toString() + "\">" + obj[k].toString() );
                   //JOptionPane.showMessageDialog(null, "BU : in else " );
              else {
         %>     
              <option value= "assignedeng"> Assigned Engineer
              <% } %>
         </select></td>
         <td></td>
         </tr><tr></tr><tr></tr><tr></tr><tr></tr>
         <tr>
         <td colspan=1><font FACE="VERDANA,ARIAL" size=2></font></td>
         <td>
         </td>
         <td colspan=2>
    <!--      <input type=hidden name=AssignedBusinessUnit value="<%=assignedbu%>"> -->
         <input type=button value="Generate Report" onClick ="PrintReport()">     </td>
    </tr>
    </form>

  • Passing values to current jsp page to another jsp page in ADF

    Hi All,
    In my adf application i want to get the appropriate field value of selected row and i want to send that value to the another jsp page from curent jsp page when will we click on button or link.How can i do this.Please give me your valuable suggestions.I'm using jdeveloper 11.1.1.5 version. Thanks!

    Hi,
    Thanks for the reply. I didnt understand the execution of the process. can you please send any sample for text like hello world is passing to second jsp page. or any simple sample?

  • How to pass values from single Databank file across different scripts?

    Hi Guys,
    I have a question regarding using single databank file across different scripts.
    Lets say there 5 web service scripts and these are very generic scripts where the input/request xml schema of each script is parameterized without having any databank as script asset.
    These 5 web service scripts are like library functions and so we dont want to attach any databank as script asset.
    However I have a driver script to call all of these 5 library scripts and now I attach a databank (a .csv file) to the driver script as script asset. Say this .csv file has got 10 different columns with just single record/row.
    As and when the function call goes to those 5 scripts i.e one by one, then based on the function call the corresponding columns are used and the data for those columns must be read.
    Is there any solution to acheive this?
    Faster help is highly appreciated.

    Hi JB,
    what i was looking for, was an approach to use a databank file (.csv file) in a parent script and then by reading that .csv file, the data should be moved from the parent script to individual child scripts.
    The child scripts are very generic scripts and are like library functions which are not data dependent. they are fully parameterized and they dont have any sort of databank attached to them.
    Now the question is if the databank has got 10 columns where first 3 columns belong to one child script, second 3 columns belong to 2nd child script and so on.
    Then how do we pass the values from parent script to a child script and what is the best/recommended approach.

Maybe you are looking for