Value comparison on jsp page

Hi
I want to compare value stored in bean object with another value to show suitable message on page
Eg
if(#{bean.userstatus=="N"}){
//show this
}else{
//show this
Can anybody please tell me how to do comparison as examplified above
Thanks

Use the 'rendered' attribute. It accepts a boolean expression. If it evaluates to false, then the component simply won't be rendered in the component root, otherwise so.
Here are some basic examples:<h:someComponent rendered="#{myBean.booleanValue}" />
<h:someComponent rendered="#{myBean.intValue > 10}" />
<h:someComponent rendered="#{myBean.objectValue == null}" />
<h:someComponent rendered="#{myBean.stringValue != 'someValue'}" />
<h:someComponent rendered="#{!empty myBean.collectionValue}" />
<h:someComponent rendered="#{!myBean.booleanValue && myBean.intValue != 0}" />
<h:someComponent rendered="#{myBean.stringValue == 'oneValue' || myBean.stringValue == 'anotherValue'}" />In your specific case, just do:<h:someComponent rendered="#{bean.userstatus == 'N'}" />
<h:someComponent rendered="#{bean.userstatus != 'N'}" />

Similar Messages

  • 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>

  • 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.

  • 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

  • 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") %>">

  • How can we pass selected combo box value to a jsp pag?

    Hi All,
    I want to pass selected combo box value to a same jsp page's variable.
    i am using javascript
    <select onchange="this.options[this.selectedIndex].text">
    </select>
    this selected value should be invoked for a jsp page's variable.
    Excepting for favorable reply
    Vansh

    select2.jsp
    <script>
    function x()
         alert(document.f.s.options[document.f.s.selectedIndex].text);
         document.f.submit();
    </script>
    <body>
    <form method="get" name="f" action="select2.jsp">
    <select name="s" onchange="x()">
    <option checked>--select--</option>
    <option value="1"> vijay </option>
    <option value="2"> kumar </option>
    </select>
    </form>
    </body>

  • Bean Value display in JSP Page

    Hi,
    I am trying to display a value stored in my bean on the jsp page. The value is to be displayed on the initial jsp page.
       public void doInitialization()
              request = (IPortalComponentRequest) this.getRequest();
              response = (IPortalComponentResponse) this.getResponse();
              myContext = request.getComponentContext();
              myProfile = myContext.getProfile();      
              Statement += "doInitialization";
              BeanContainer = new MockUpBean();
              BeanContainer.setValues( Statement);
              myProfile.putValue( "myBean", BeanContainer);
              // reset String
              BeanContainer = ( MockUpBean) myProfile.getValue( "myBean");     
        }// public void doInitialization()
    On the JSP Page side:
    <jsp:useBean id="myBean" scope="application" class="MockUpBeanPackage.MockUpBean" />
    <%= myBean.getValues()%>
    The jsp page does no pick up the value I try to store in the doInitialise method.
    Any thoughts on what I may have done wrong in my code.
    I try response.write("Test"), this too does not show up in my JSP page.
    Any advice would be appreciated.
    Thank you
    NAC

    Marty,
    The portalapp.xml file is as follows:
    <?xml version="1.0" encoding="utf-8"?>
    <application>
      <application-config>
        <property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>
      </application-config>
      <components>
        <component name="MockUpPage">
          <component-config>
            <property name="ClassName" value="MockUpPackage.MockUpPage"/>
            <property name="SecurityZone" value="MockUpPackage/low_safety"/>       
            <property name="ComponentType" value="jspnative"/>
            <property name="JSP" value="pagelet/InitialPage.jsp"/>
          </component-config>
          <component-profile>
            <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
          </component-profile>
        </component>
      </components>
      <services/>
    </application>
    Again any help would be apreciated. I have used this piece of code to write values to beans in various projects, never had any issues. This is the first time I am having an issue with this piece of code.
    NAC

  • 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 convert text values acceses from jsp page into an xml file?

    /* this is the jsp page which i want to convert it into an xml file
    please help me , i thank in advance*/
    <html>
    <head>
    <title> xml test</title>
    </head>
    <body>
    <form action="testxml2.jsp" method = post>
    <ul>
    <li>
    <ul>NAME:
    <br>
    <li>First Name:<INPUT NAME="firstName" TYPE=text SIZE=20><br>
    <li>Middle Name:<INPUT NAME="middlename" TYPE=text SIZE=20><br>
    <li>Last Name:<INPUT NAME="lastname" TYPE=text SIZE=20><br>
    <li>t Name:<INPUT NAME="tname" TYPE=text SIZE=20><br>
    </ul>
    <br>
    <ul>Role:</b><p><input type="radio" name="role" value="buyer">Buyer<p>
              <input type="radio" name="role" value="seller">Seller<p>
              <input type="radio" name="role" value="thirdparty">Third Party<p>
    </ul>
    <ul>
    Qualification:<br>
    <li>Highest Degree:<INPUT NAME="degree" TYPE=text SIZE=20><br>
    <li>Percentage: <INPUT NAME="percentage" TYPE=text SIZE=20><br>
    </ul>
    <ul> Adress:
    <li> streetName:<INPUT NAME="street" TYPE=text SIZE=20><br>
    <li>cityName:<INPUT NAME="city" TYPE=text SIZE=20><br>
    <li>StateName:<INPUT NAME="state" TYPE=text SIZE=20><br>
    </ul>
    </ul>
    <b>
    <INPUT TYPE=SUBMIT VALUE="ENTER" >
    </body>
    </html>

    hi there,
    In the MCV there is a part about struts, this is a descent way to do this.
    how to do it:
    create an actionform containing all the properties of the page.
    then when you submit your form use an method in the actionforms (that you have written) that makes sets your data in a xml file.
    this works very quickely and i use it in production...
    you can choose if you want the xml to generaded hard coded or via a parser.
    greetings

  • Values on the jsp page not loading after refresh

    Hi All,
    I have a problem in getting the values back onto the jsp page after a refresh. After the first refresh i get null values.
    Let me know what i should use: is it 1. request 2. application or 3. session scope? I have to keep my application running for ever (as long as the server is running) refreshing every 3 minutes. So i used application scope but in vain.
    Also i am using requestDispatcher and forwarding the req,res. I came to know that this method has some problems if we use request attributes. Do i need to use a send.Redirect instead?
    Let me know the correct procedure.
    Thanks in advance.

    Gouri-Java wrote:
    Hi All,
    I have a problem in getting the values back onto the jsp page after a refresh. After the first refresh i get null values.
    Let me know what i should use: is it 1. request 2. application or 3. session scope? I have to keep my application running for ever (as long as the server is running) refreshing every 3 minutes. So i used application scope but in vain.
    Also i am using requestDispatcher and forwarding the req,res. I came to know that this method has some problems if we use request attributes. Do i need to use a send.Redirect instead?
    Let me know the correct procedure.
    Thanks in advance.r u forwarding request to same page. ?
    try using sendRedirect with URL rewriting:
    for eg .
    response.sendRedirect("/myPage.jsp?id="+idValue+"");
    and access id on page submit.
    as
    request.getParameter("id");
    This should work .
    Edited by: AmitChalwade123456 on Jan 6, 2009 7:10 AM

Maybe you are looking for

  • Rs480 windows-sata installation problem

    Hi all,             Whenever I try to install windows in my system I press the F6 button and loads the sil3112 sata driver. The first time I tried this worked(win xp with no sps) and I got to install windows. But after sometime I decided reinstall wi

  • Getting error when creating a RFQ in MM module" create rfq item overview"

    Hi, i am a beginer in SAP administration, users are getting this error message and i have done all my research and not able to resolve this issue. This error i am getting when creating a RFQ in MM module and when trying to save the screen "create rfq

  • Photoshop Lightroom not detecting my camera

    I can't connect connect my NIKON dslr d5500 with photoshop lightroom 5 will you tell me how can i connect this dslr with lightroom????

  • BAPI_CONTRACT_CREATEFROMDATA Billing Plan Tab

    In BAPI_CONTRACT_CREATEFROMDATA I cannot figure out how to populate the 'Billing Plan' tab information in the header data. The table that this information is stored in is table FPLA.

  • PHP5 SOAP WSDL and Xcelsius 2008 communication error

    Hi, I wood like to use PHP5 Soap server and WSDL for Xcelsius2008. Now Xcelsius 2008 can read WSDL parameters, and data from Xcelsius appear in Soap server, but in the Soap Response is the error message: <?xml version="1.0" encoding="UTF-8"?> <SOAP-E