Returning Values to a JSP Page

I have a servlet that recives data from a form using POST. Once I've processed the data I need to pass my new data (and some of the original data) to a new JSP page.
This was originally done using response.sendRedirect with all the data held within a parameter string.
We've now been told that we've not to pass any data via URL's, Is there a way to secruley pass data back to a jsp page.
I thought about using:-
protected void transferToRD(String target, HttpServlet servlet, HttpServletRequest req, HttpServletResponse res)
try
RequestDispatcher rd = servlet.getServletContext().getRequestDispatcher(target);
rd.forward(req, res);
catch (Exception exc)
exc.printStackTrace();
But I don;t have a servlet to pass in as a parameter
Any help would be appreciated

Or you can use one of these in the JSP page:
<jsp:usebean id="var_name" class="class_name" scope="request">Only thing to remember is that if it can't find the variable name then it will call the default constructor to create a new instance, and if that doesn't exist then you will get a runtime error in your JSP page which looks pretty ugly.

Similar Messages

  • How to get the return values from a web page

    Hi all :
       how to get the return values from a web page ?  I mean how pass values betwen webflow and web page ?
    thank you very much
    Edited by: jingying Sony on Apr 15, 2010 6:15 AM
    Edited by: jingying Sony on Apr 15, 2010 6:18 AM

    Hi,
    What kind of web page do you have? Do you have possibility to for example make RFCs? Then you could trigger events (with parameters that could "return" the values) and the workflow could react to those events. For example your task can have terminating events.
    Regards,
    Karri

  • How can I share values between different jsp pages?

    Hi,
    I'm doing a jsp, bc4j application (JDeveloper 9.0.3), and I need to share some values between different jsp pages. To do this,
    I have used the tag <jsp:usebean.....></jsp:usebean> in this way:
    on pageone.jsp
    <jsp:useBean id="param" scope="session" class="MyPackage.Parameters" ></jsp:useBean>
    on pagetwo.jsp     
    <jsp:useBean id="param" scope="session" class="MyPackage.Parameters" ></jsp:useBean>
    and so on, in order to refer to the same instance of the class "Parameters".
    After deploying, the application works well only if the client is the same pc where the AS resides, otherwise the variables of "Parameters" are null.
    Please, could you help me?
    Thanks
    Nunzio.

    I am seeing an indication on 9.0.3 that static includes are not static, but instead always dynamic. The compiler generates a call to the included page, and doesn't include the content in the calling page as it should.

  • Get Javascript Value in a JSP page

    Let's say this is my javascript function in a html page
    .<head>
    <!-- Function getFields -->
    function getFields(){
    if (row >= 0){
    for(var i=0; i<costForm.elements.length; i++){
    if(costForm.elements.type == "text" || costForm.elements[i].type == "hidden"){
    dynTableFields[i] = (costForm.elements[i].value)? costForm.elements[i].value : "";
    if(costForm.elements[i].type == "select-one"){
    dynTableFields[i] = costForm.elements[i].selectedIndex;
    </head>
    How do i get the costForm.elements.length value in another jsp page. Coz the html page has dynamic rows by the users. and i need the values in the jsp page to know how many rows the user created.
    using normal request.getParameter("costForm.elements.length") doesn't work

    request.getParameter() will only get data that's been submitted thru a form or the query string of a URL. You'd have to record the length in a hidden field to read it on the back end, and then you can't just loop thru the fields like that in JSP on the server anyway, unless you have all fields named with a prefix and number, like: field1, field2, field3, etc.

  • 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

  • HOW to send a value to another jsp page

    HOW to send a value to another jsp page, like user name in one jsp page to another jsp page

    In the most simplest form...
    // pageA.jsp
    <html>
    <body>
    <form action="pageB.jsp" method="post">
    <b>First Name:</b> <input type="text" name="FNAME" value="Joe">
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>
    // pageB.jsp
    <html>
    <body>
    <b>Name:<b> <%=request.getParameter("FNAME")%>
    </body>
    </html>

  • LOV does not return value to the base page sometimes

    Hi,
    I have created messageLOV type items. These LOVs do return value to the base page usually. We have a user in Uruguay who is trying to use the page which has the LOVs. He says the LOV takes a long time to return to the main page after he clicks on quick select and also the value does not get populated in the main page.
    We have not been facing any such problem here in India. The LOV has been tested rigorously with no issues as such.
    Can you please suggest a reason why such a problem is occuring? Expecting your replies soon
    Thanks,
    Priya

    Thiyaga, did you read the devguide or the tutorial ?
    Can you please give me the inputs about the creation of LOV and it requires how many lov mappings as mandatory?
    This is there in the devguideHow to identify the mapping fields of an LOV which is already existing in the base page to reproduce in a similar way and need to do a customization on top of it ?
    Open the page XML and you can find the LOV mappings.Tapash

  • Values from a jsp page are null in Action Class

    hi, i am working on an application...i have a jsp page with several inputs (type=text) and when a submit the form to to my action class all values      received are null.
    Here is a part of code:
    the jsp file: letter.jsp
    <form target="_self" action="/Test/editLetter.do" name="letterTF">
    <table>
    <tbody>
    <tr>
    <th>
    No of objects
    </th>
    <th>
    Weight
    </th>
    <th>
    Description
    </th>
    </tr>
    <tr>
    <td>
    Package
    <input name="package" id="package" type="checkbox">
    </td>
    <td>
    <input name="package_No" type="text" value="<%=currentBean.getPackageNo() %>"> <%-- from session...have to edit some date from a data base--%>
    </td>
    <td>
    <input name="package_weight" type="text" value="<%=currentBean.geWeight()%>">
    </td>
    <td>
    <input name="description" type="text" value="<%=currentBean.Description()%>"
    </td>
    </tr>
    <tr>
    ..................................................... <%-- It's a big form --%>
    </tr>
    <tr>
    <input type="submit" name="send" value="Send">
    </tr>
    </tbody>
    </table>
    </form>
    struts-config.xml:
    <form-bean
              name="letterTF"
              type="Test.LetterForm">
    </form-bean>
    <action path="/editLetter"
                   type="Test.LetterAction"
                   name="scrisoareTF"
                   input="/letter.jsp"
                   scope="request"
                   validate="false">
                   <forward name="success" path="/index_orders.jsp"/>
    </action>
    The ActionForm class:
    public class LetterForm extends ActionForm{
    private String package;
         private String package_No;
         private String package_weight;
         public void setPackage(String package){
    this.package = package
    public String getPackage(){
    return package;
    The action class:
    public class LetterAction extends Action{
    public ActionForward execute(     
                   ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response)
         throws Exception{
    String package;
    String package_No;
    String package_weight;
    LetterForm letterTF = (LetterForm) form;
    package = letterTF.getPackage();
    package_No = letterTF.getPackageNo()
    package_weight = letterTF.getPackageWeight();
    System.out.println("Package: "+package);//it will print Package: null
    System.out.println("Weight: "+weight);//it will print Weight: null
    System.out.println("Description "+description) //it will print Description: null
    As I observed its not making the set methods from LetterForm.java
    I am dealing with this bug for a couple of days an i didn't managed to break it. If anyone has an idea would he be so kind to share it with me.
    Thanks in advanced,
    David

    Basically your form beans are the place holders or containers for your jsp attributes. It has to be mapped in such a way that when the form is submitted the user entered values get populated on to your form bean.
    For Eg:
    JSP
    <html:form action="accountSearchResults.do">
    <html:text property="myName" size="15"/>
    //USE ONLY STRUTS TAGS IN JSP's. U CAN REFER TO
    //http://struts.apache.org/1.x/struts-taglib/tlddoc/index.html
    //THE PROPERTY NAME "myName" SHOULD BE DEFINED IN
    //YOUR FORMBEAN WITH getMyName AND setMyName
    //METHODS DEFINED
    </html:form>
    struts-config.xml
    <form-beans>
         <form-bean name="addEditAccount" type="org.apache.struts.validator.LazyValidatorForm">
              <form-property name="myName" type="java.lang.String">
              </form-property>
         </form-bean>
    </form-beans>
    <action-mappings>
         <action path="/accountSearchResults" type="com.zzz.AccountSearchResultAction" name="addEditAccount" scope="request">
              <forward name="success" path="NextPage.jsp">
              </forward>
         </action>
    </action-mappings>
    Action Class
    Since we have defined the form bean as a lazyvalidator instance you can use:
    PropertyUtils.copyProperties(targetBean, form);to fetch the values entered by the user. Try to use struts tags in your jsp's and map the properties to your form bean variables. Hope that helps.
    SirG

  • Values from a jsp page are null in an Action class

    hi, i am working on an application...i have a jsp page with several inputs (type=text) and when a submit the form to to my action class all values received are null.
    Here is a part of code:
    the jsp file: letter.jsp
    <form target="_self" action="/Test/editLetter.do" name="letterTF">
    <table>
    <tbody>
    <tr>
    <th>
    No of objects
    </th>
    <th>
    Weight
    </th>
    <th>
    Description
    </th>
    </tr>
    <tr>
    <td>
    Package
    <input name="package" id="package" type="checkbox">
    </td>
    <td>
    <input name="package_No" type="text" value="<%=currentBean.getPackageNo() %>"> <%-- from session...have to edit some date from a data base--%>
    </td>
    <td>
    <input name="package_weight" type="text" value="<%=currentBean.geWeight()%>">
    </td>
    <td>
    <input name="description" type="text" value="<%=currentBean.Description()%>"
    </td></tr>
    <tr>
    ..................................................... <%-- It's a big form --%>
    </tr>
    <tr>
    <input type="submit" name="send" value="Send">
    </tr>
    </tbody>
    </table>
    </form>
    struts-config.xml:
    <form-bean
    name="letterTF"
    type="Test.LetterForm">
    </form-bean>
    <action path="/editLetter"
    type="Test.LetterAction"
    name="scrisoareTF"
    input="/letter.jsp"
    scope="request"
    validate="false">
    <forward name="success" path="/index_orders.jsp"/>
    </action>
    The ActionForm class:
    public class LetterForm extends ActionForm{
    private String package;
    private String package_No;
    private String package_weight;
    public void setPackage(String package){
    this.package = package
    public String getPackage(){
    return package;
    The action class:
    public class LetterAction extends Action{
    public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception{
    String package;
    String package_No;
    String package_weight;
    LetterForm letterTF = (LetterForm) form;
    package = letterTF.getPackage();
    package_No = letterTF.getPackageNo()
    package_weight = letterTF.getPackageWeight();
    System.out.println("Package: "+package);//it will print Package: null
    System.out.println("Weight: "+weight);//it will print Weight: null
    System.out.println("Description "+description) //it will print Description: null
    As I observed its not making the set methods from LetterForm.java
    I am dealing with this bug for a couple of days an i didn't managed to break it. If anyone has an idea or a solution would he be so kind to share it with me
    Thanks in advance,
    David

    Basically your form beans are the place holders or containers for your jsp attributes. It has to be mapped in such a way that when the form is submitted the user entered values get populated on to your form bean.
    For Eg:
    JSP
    <html:form action="accountSearchResults.do">
    <html:text property="myName" size="15"/>
    //USE ONLY STRUTS TAGS IN JSP's. U CAN REFER TO
    //http://struts.apache.org/1.x/struts-taglib/tlddoc/index.html
    //THE PROPERTY NAME "myName" SHOULD BE DEFINED IN
    //YOUR FORMBEAN WITH getMyName AND setMyName
    //METHODS DEFINED
    </html:form>
    struts-config.xml
    <form-beans>
         <form-bean name="addEditAccount" type="org.apache.struts.validator.LazyValidatorForm">
              <form-property name="myName" type="java.lang.String">
              </form-property>
         </form-bean>
    </form-beans>
    <action-mappings>
         <action path="/accountSearchResults" type="com.zzz.AccountSearchResultAction" name="addEditAccount" scope="request">
              <forward name="success" path="NextPage.jsp">
              </forward>
         </action>
    </action-mappings>
    Action Class
    Since we have defined the form bean as a lazyvalidator instance you can use:
    PropertyUtils.copyProperties(targetBean, form);to fetch the values entered by the user. Try to use struts tags in your jsp's and map the properties to your form bean variables. Hope that helps.
    SirG

  • Priocntl system call returning values not in man page

    If you look at the man page for priocntl(2) it says that pc_clname in pcinfo_t will only contain the following values:
    RT for realtime
    TS for time-share
    FX for fixed-priority
    but I've also seen the following returned
    FSS presumably for Fair share
    IA presumable for Interactive
    Is this just a doc bug or is priocntl not supposed to be passing these back. The way priocntl(1) and (2) read I was inferring that the difference was somewhat on purpose in that Interactive mode is just a special Time Share mode and thus would show up as TS when queried using priocntl(2).
    You may ask who cares but we use a third party class library (RW) and the version of the code we have, which I will admit is old, only handles TS and RT coming back from priocntl, exceptions when IA comes back.
    On a related note, does anyone know if a "workstation" machine will somehow default to Interactive mode for some processes, namely the ones not started at boot time? On a server box, e450, if you run 'priocntl -d -i all. All the processes show up under Time Share but if I run the same
    command on a workstation box, sparc 5, I get that some are in Time Share and others are in Interactive.
    Thanks.

    Or you can use one of these in the JSP page:
    <jsp:usebean id="var_name" class="class_name" scope="request">Only thing to remember is that if it can't find the variable name then it will call the default constructor to create a new instance, and if that doesn't exist then you will get a runtime error in your JSP page which looks pretty ugly.

  • Struts where are values stored between jsp pages?

    Hi.I realize that this is forum is not specifically for struts but I thought someone might know the answer to my question.
    I have run the following code. The code contains two JSP’s that both get there values from the same ArrayList generated by the same actionform so contain the same data. Example.jsp is diplayed when the application is first run when submit is clicked newjsp.jsp is displayed.
    If a value in the fields of example.jsp is changed and submit is clicked the altered value is also displayed in newjsp.jsp. I am confused by this as after submit is clicked ExampleForm.java method reset is called which returns the variable values to their original value but the newly entered value is still displayed. Please tell me how this works
    Example.jsp
    <%@ page language="java"%>
    <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
    <%@ taglib uri="http://struts.apache.org/tags-nested" prefix="nested"%>
    <html>
        <head>
            <title>JSP for exampleForm form</title>
        </head>
        <body>
            <html:form action="/example">
                <h3>Use of nested:iteration tag</h3>
                <nested:nest property="department">
         DEP. ID: <nested:text property="id"/> <br />
         NAME: <nested:text property="name"/> <br /><br />
                    <nested:iterate property="customers">
                        <b>Customer info</b><br />
              CUST. ID: <nested:text property="id"/> <br />
              NAME: <nested:text property="name"/> <br />
                    </nested:iterate>
                </nested:nest>
                <br />
                <br />
                <html:submit/><html:cancel/>
            </html:form>
        </body>
    </html>
    Newjsp.jsp
    <%@ page language="java"%>
    <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
    <%@ taglib uri="http://struts.apache.org/tags-nested" prefix="nested"%>
    <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
    <html>
        <head>
            <title>JSP for exampleForm form</title>
        </head>
        <body>
            <html:form action="/example">
                <h3>Use of nested:iteration tag</h3>
                <nested:nest property="department">
                    <table>
                        <nested:iterate property="customers">
                            <tr><td>Customer info</td>
                                <td>CUST. ID: <nested:text property="id"/> </td>
                                <td>NAME: <nested:text property="name"/> </td>
                            </nested:iterate>
                        </tr>
                    </table>
                </nested:nest>
                <br />
                <br />
                <html:submit/><html:cancel/>
            </html:form>
        </body>
    </html>
    ExampleAction.jsp
    package de.laliluna.tutorial.nested.action;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import de.laliluna.tutorial.nested.form.ExampleForm;
    import de.laliluna.tutorial.nested.object.*;
    import java.util.*;
    public class ExampleAction extends org.apache.struts.action.Action {
        /* forward name="success" path="" */
        private static final String SUCCESS = "success";
        @Override
        public ActionForward execute(ActionMapping mapping, ActionForm form,
                HttpServletRequest request, HttpServletResponse response)
                throws Exception {
            ExampleForm formBean = (ExampleForm) form;
            Department depart = formBean.getDepartment();
            ArrayList dep = (ArrayList) depart.getCustomers();
            Customer cust0 = (Customer) dep.get(0);
            System.out.println(">>>>>>>>>>>>>> customer.getName() = " + cust0.getName());
            System.out.println(">>>>>>>>>>>>>> customer.getId() = " + cust0.getId());
            Customer cust1 = (Customer) dep.get(1);
            System.out.println(">>>>>>>>>>>>>> customer.getName() = " + cust1.getName());
            System.out.println(">>>>>>>>>>>>>> customer.getId() = " + cust1.getId());
            Customer cust2 = (Customer) dep.get(2);
            System.out.println(">>>>>>>>>>>>>> customer.getName() = " + cust2.getName());
            System.out.println(">>>>>>>>>>>>>> customer.getId() = " + cust2.getId());
            return mapping.findForward("example");
    ExampleForm.jsp
    package de.laliluna.tutorial.nested.form;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionMessage;
    import de.laliluna.tutorial.nested.object.*;
    import java.util.ArrayList;
    import java.util.Collection;
    public class ExampleForm extends org.apache.struts.action.ActionForm {
        Department department;
        public Department getDepartment() {
            return department;
        public void setDepartment(Department department) {
            this.department = department;
        public void reset(ActionMapping mapping,
                HttpServletRequest request) {
            System.out.println("Entered action bean reset");
            Collection customers = new ArrayList();
            customers.add(new Customer(1, "Maria"));
            customers.add(new Customer(2, "Klaus"));
            customers.add(new Customer(3, "Peter"));
            department = new Department(1, "Department A", customers);
    Customer.java
    package de.laliluna.tutorial.nested.object;
    public class Customer {
        private int id;
        private String name;
        public Customer() {
        public Customer(int id, String name) {
            this.id = id;
            this.name = name;
        public int getId() {
            return id;
        public void setId(int id) {
            this.id = id;
        public String getName() {
            return name;
        public void setName(String name) {
            this.name = name;
    Department.java
    package de.laliluna.tutorial.nested.object;
    import java.util.Collection;
    public class Department {
        private int id;
        private String name;
        private Collection customers;
        public Department() {
        public Department(int id, String name, Collection customers) {
            this.id = id;
            this.name = name;
            this.customers = customers;
        public Collection getCustomers() {
            return customers;
        public void setCustomers(Collection customers) {
            this.customers = customers;
        public int getId() {
            return id;
        public void setId(int id) {
            this.id = id;
        public String getName() {
            return name;
        public void setName(String name) {
            this.name = name;
    }

    Thanks for responding.
    I set the debugger as you suggested and found that method reset is being called.
    I did not write the whole of this program I was just playing around with and expanding a struts example I found on line.
    http://www.laliluna.de/articles/struts-nested-iteration-tutorial.html
    It contains the reset method.
    I am interested to know how to reset the values. So am clearing the data after it has been submitted, just to reset. I assumed that once the new page was arrived at the values would be taken from the array.
    I am quite new to struts and am not familiar with example_input.action and example.action I will look into these.

  • Help needed urgently to get the values from the jsp page.

    hi,
    I am badly stuck into this problem.Please help me and find a solution.
    I am using ms-access and jsp.
    my database structure is as given below:
    m_emp_no | from_date | to_date | approver| status |
    1002 | 22/9/2008 | 23/9/2008|1003 |pending
    1004 | 29/9/2008 | 30/9/2008|1003 |pending
    2044 | 15/9/2008 | 16/9/2008|3076 |pending
    now this is exactly a leave apply scenario where a page is displayed and the user has to fill in the details to apply leave.then the approver has to approve that leaves so even, he should get the details in his account.
    for example here 1003 has to approve leaves for 1002 & 1004.i am able to fetch data from database for the particular approver here is the coding:
    <html>
    <body>
    <h2 align="center"><u><b><span style="background-color: #FFFFFF"><font color="#C0C0C0" face="Comic Sans MS">Leave
    Approval Requests</font></span></b></u></h2>
    <form method="POST" name="f1" action="update.jsp">
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:employee_details");
    PreparedStatement p=null;
    p=con.prepareStatement("select * from emp_leave_application where approver='"+username+"'");
    ResultSet r=p.executeQuery();
    while(r.next())
    %>  <table border="1" width="100%" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
        <tr>
          <td width="100%" bgcolor="#999966"><b><u><%=r.getString(2)%></u></b></td>
        </tr>
      </table>
      <table border="1" width="100%" height="171" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
        <tr>
          <td width="100%" height="165" valign="top">
            <p align="left"><b>User ID</b>        :
    <input type="text" name="id" value="<%=r.getString(1)%>"  size="4   
         <b>status</b>:<%=r.getString(5)%</p>
    <p><b>Leave From</b> : <%=r.getString(2)%></p>
    <p><b>Leave From</b> : <%=r.getString(3)%></p>
    <p><b>Approve</b> : <select  size="1" name="approved">
            <option value="Approved">Approved</option>
            <option value="Cancelled">Cancelled</option>        </select></p>
    <%
    con.close();
    %>
      <table border="1" width="100%" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
              <tr>
                <td width="100%" bgcolor="#999966">
                  <p align="center"><input type="reset" value="Clear" name="B1"> 
                  <input type="submit" value="Submit" name="B2"></td>
              </tr>
            </table>
            </td>
        </tr>
      </table>
    </form>
    </body>
    </html>{code}
    this will display both the rows but when i try to retrieve the values into update.jsp using the code given below it gives me only one value which is the first 1002.
    {code}approved=(String)request.getParameter("approved");
    id=(String)request.getParameter("id");{code}
    but i need both the values to be inserted into the update.jsp only then the approver will be able to approve the leaves individually with respect to the m_emp_no.
    please help me out.
    thanks in advance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    My comments below are all between (((((( and ))))))
    <html>
    <body>
    <h2 align="center"><u><b><span style="background-color: #FFFFFF"><font color="#C0C0C0" face="Comic Sans MS">Leave
    Approval Requests</font></span></b></u></h2>
    <form method="POST" name="f1" action="update.jsp">
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:employee_details");
    PreparedStatement p=null;
    p=con.prepareStatement("select * from emp_leave_application where approver='"+username+"'");
    ResultSet r=p.executeQuery();
    while(r.next())
    %> <table border="1" width="100%" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
    <tr>
    <td width="100%" bgcolor="#999966"><b><u><%=r.getString(2)%></u></b></td>
    </tr>
    </table>
    <table border="1" width="100%" height="171" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
    <tr>
    <td width="100%" height="165" valign="top">
    <p align="left"><b>User ID</b> :
    <input type="text" name="id" value="<%=r.getString(1)%>" size="4   
    ((((((( in the statement above, name="id" should be changed to something like name="id"<%=ii%>
    Where ii is a counter that tells you how many times you have gone through the loop so far.
    The reason for this is that each textfield you generate must have a unique name rather than all have the same name
    such as 'id'. This change will give them names such as id0, id1, id2. Then when you submit the page, you can uniquely
    identify each input textfield.))))))
    <b>status</b>:<%=r.getString(5)%</p>
    <p><b>Leave From</b> : <%=r.getString(2)%></p>
    <p><b>Leave From</b> : <%=r.getString(3)%></p>
    <p><b>Approve</b> : <select size="1" name="approved">
    (((( the above select also has to have a unique name for each time through the loop. Change it to name="approved"<%=ii%>
    <option value="Approved">Approved</option>
    <option value="Cancelled">Cancelled</option> </select></p>
    <%
    con.close();
    %>
    <table border="1" width="100%" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
    <tr>
    <td width="100%" bgcolor="#999966">
    <p align="center"><input type="reset" value="Clear" name="B1">
    <input type="submit" value="Submit" name="B2"></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    (((((((note you would be better off long term to put your business logic in a servlet and dispatch to the JSP page which will only have the responsiblity to display the data.
    Also, connection pooling is better than the above.

  • How to return values from a BSP page to Javascript

    Hi All,
    I want to call a BSP page which reads a single value from a table and returns that value I want the Javascript in the HTML code to get the value from the BSP page.
    Can you kindly let me know how I can return the value from the BSP page to JavaScript.
    Kindly please provide me a simple code of a BSP page and the Javascript
    Thanks
    Karen

    Hi,
    you need 3 elements to make the javascript code read the value in any field in the table: table´s name, line and column. This is how your code could look like:
    script language="javascript>
       var row = 0;
       function display(){
          row = row + 1;
          campo = 'tabla1_' + row + '_4';                 " <-- table, line, column
          valor = document.getElementById(campo).value;
    </script>
    ROW works as a counter. You have in variable valor the value of the field and can do with it what you want, perhaps display it with ALERT. I am reading the values from field 1 to n in column 4 in table TABLA1. Pay attention to the '_' in the concatenation of field´s name. The table in my BSP is very simple:
    <htmlb:tableView id                = "tabla1"
                           table             = "<%= mytable %>"
                           width             = "100%"
                           allRowsEditable   = "X"/>
    and somewhere I must call function display in my javascript code:
    <htmlb:button  id="boton" text="Texto aqui" onClientClick="display()" />
    So, give it a try.

  • How to get the value in one JSP page to another?

    Hi,
    I have problems in passing the value around in JSP. I have two JSP pages as below:
    test1.jsp
    I try to get the vaule from my textbox by using:
    String strUser = request.getParameter ("strUserName");
    Then i print out by using: out.print(strUser); then i can get the value and put on my page (For example, i get ABC on my page).
    test2.jsp
    Next, i want to get the value from strUser (which mean that the one i already display on page in test1.jsp, ABC) to insert into my table by using INSERT INTO statement. Then i try by using
    String strUser1 = request.getParameter ("strUser");
    Is it possbile for me to do that? I cannot get anything to insert into my table. Then i tried out.print(strUser1); then i found that i get NULL value.
    Could you please give me some guidance?
    Thanks you very much for any advise you may give me.
    Kimsan

    Hi,
    Thank you very much for your help. It's working fine if i just get a one value to another page, however, i have problem while i pass the value in my loop to another page because i always get the last record. I try with the following code:
    logged_page.jsp
    <html>
    <head>
    <title>Welcome to the online Auction...</title></head>
    <body>
    <%@ page language ="java" import = "java.io.*, java.lang.*, java.sql.*" %>
    <% try
         String strUsername = request.getParameter("username");
         session.setAttribute("myUserName", strUsername);     
         String strPassword = request.getParameter("password");
         Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
         Connection myConn = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/Auction/Auction.mdb");
         String strSQL = "SELECT [UserName], [Password] FROM tblUserDetails where [UserName] = ? and [Password] = ?";
         PreparedStatement statement = myConn.prepareStatement(strSQL);
         statement.setString(1, strUsername);
         statement.setString(2, strPassword);
         ResultSet myResult = statement.executeQuery();
         if(myResult.next())
         //out.println("Login Succesful! A record with the given user name and password exists");
         out.print("<center><h1>");
         out.print("Welcome  ");
         out.print(strUsername);
         out.print("</h1></center>");
         out.print("<center>");
         out.print("<BR><BR>");
         out.print("<font font face = Viner Hand ITC size= 5>Products on sales</font>");
         out.print("<BR><BR>");
         Statement myStatement = myConn.createStatement ();
         ResultSet myResult1 = myStatement.executeQuery("SELECT * FROM tblProduct");
         ResultSetMetaData myResultSet = myResult1.getMetaData();
         out.println("<font face=Tahoma>");
         out.print("<table border=1 CELLSPACING=0>");
         out.print("<TR>");
         out.print("<TD width = 200> Item Title");out.print("</TD>");
         out.print("<TD width = 200> Description");out.print("</TD>");
         out.print("<TD width = 200> Current bid");out.print("</TD>");
         out.print("<TD width = 200> Available Time");out.print("</TD>");
         out.print("<TD width = 200> Place Bid");out.print("</TD>");
         out.print("</TR>");
         out.print("</table>");
         while(myResult1.next())
              String strProName = myResult1.getString(1);
              session.setAttribute("myProName", strProName);          
              out.print("<table border=1 CELLSPACING=0>");
              out.print("<TR>");
              out.print("<TD width = 200>");
              out.println(strProName);
              out.print("</TD>");
              out.print("<TD width = 200>");
              out.println(myResult1.getString(3));
              out.print("</TD>");
              out.print("<TD width = 200>");
              out.println(myResult1.getString(2));
              out.print("</TD>");
              out.print("<TD width = 200>");
              out.println(myResult1.getString(4));
         out.print("</TD>");
         out.print("<TD>");
              out.print("<form action=bid_page.jsp method=post>");
              out.print("<input type=text name=place_bid>");
              out.print("<input type=submit name=okfunc value=Bid>");
              out.print("</TD>");
              out.print("</form>");
              out.print("</TR>");
              out.print("</table>");
              out.println("</font>");
              out.print("</center>");          
         else
              out.print("<center>");
              out.print("Sorry ");
              out.print("<font color = RED size = 5>");
              out.print(strUsername);
              out.print("</font>");
              out.print(" could not be found.");
              out.print("</center>");
         myResult.close();
         statement.close();
         myConn.close();
         catch(SQLException e)
         out.println(e);
    %>
    </body>
    </html>
    bid_page.jsp
    <HTML>
    <HEAD>
    <TITLE>Welcome to the online Auction...</TITLE>
    </HEAD>
    <BODY>
    <%@ page language ="java" import = "java.io.*" import = "java.lang.*" import = "java.sql.*" %>
    <% try
         String thisUserName = (String) session.getAttribute("myUserName");
         String thisProName = (String) session.getAttribute("myProName");
              Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
         Connection myConn = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/Auction/Auction.mdb");
         PreparedStatement myStatement = myConn.prepareStatement("INSERT INTO tblHistory VALUES ('"+thisUserName+"', '"+thisProName+"', '"+request.getParameter("place_bid")+"')");
              myStatement.executeUpdate();
              myConn.commit();
              myStatement.close();
              myConn.close();
              catch(Exception e){}
    %>
    </BODY>
    </HTML>
    When i click on the BID button in the logged_page.jsp then i always get the last record and save into my table and that is not what i want to. i want to get the result on the same row as the BID button that just click and save to my table.
    Could you please advise?
    Thanks you very much for your time and any consideration you may give me.
    Best Regard,
    Kimsan

  • How can I pass a variable  value from first jsp page to thired jsp page

    In my program ,threr are three jsp pages . I want the first pages's variable value in to thired page .How can I acess.
    I used the request.getparameter() ,but when I print the value , null value is getting .

    request parameters only last for one request.
    To save them longer than that you need to save them somewhere.
    Couple of alternatives
    1 - store them to session
    session.setAttribute("username", request.getParameter("username");
    2 - create a hidden field on page 2 and store the value from page 1 there. When you submit page2, you can get it on page3 with request.getParameter again.
    <input type="hidden" name="username" value="<%= request.getParameter("username") %>">

Maybe you are looking for

  • When do the hard drives go to sleep?

    I have the default power saver settings on my Mac Mini with Yosemite. One of the options is "Put hard disks to sleep when possible" which I currently have checked. The trouble I have been trying to get through a ClamXav virus scan on my machine since

  • XSQL-007 using Personal Oracle 8.1.6

    I get XSQL-007: Cannot acquire a database connection to process page. Io exception: The Network Adapter could not establish the connection message when running hello world demo. I have set up Oracle 8i on Windows 98, installed Oracle 8.1.6 for Window

  • Internet Explorer7 Blocking Crystal Reports 2008 CrystalReportViewer Export

    Visual Studio 2008 (VS 2008) Crystal Reports 2008 (CR 2008) Production Server: Windows Server 2003 Internet Browser: Internet Explorer 7 (IE7) Crystal Reports Version: 12.0.2000.0  on both development and production IE7 message: To help protect your

  • Dashboard Preferences: Why does Mac OS direct me to Expose and Spaces Pane?

    When I right click on the Dashboard Icon in the Dock and select "Dashboard Preferences..." I am directed to the System Preference pane for Expose and Spaces. This doesn't appear to be logical. Is there a true "Dashboard Preference" pane?

  • Call to_char, to_number or to_date with nls_pars but without a format model

    Hi      Does somebody know if there is a way to call to_char, to_number or to_date functions defining nlsparam argument and without defining the format model arument, in order to use implicit conversions. Thanks Bye Alessandro