Jsp:getProperty

Hi!
I create a JSP page wich is going to process a bean put in the session by other jsp page.
The code is like this:
<jsp:useBean id="realty" scope="session" class="com.admin.bean.Realty" />
    <jsp:setProperty name="realty" property="*" /> For the page where the user is going to enter the information and...
<jsp:useBean id="realty" scope="session" type="com.admin.bean.Realty" />
    <jsp:getProperty name="realty" property="*"/> for the page where the data processing is going to occur.
The problem I have is that once I enter the informacion on the page1 and press submit. I got the following error:
Cannot find any information on property '*' in a bean of type 'com.admin.bean.Realty'
Can sombody help me with that??
Thanks

There is no property "*" applicable to a get[/i]Property.
With [i]setProperty, it makes sense, because you are telling the computer set ALL the properties of the bean which have corresponding parameters in the request.
However getProperty is designed to display/return one property. How could you display multiple properties? So * makes no sense in that case.

Similar Messages

  • Populating combobox in jsp page from javabean using jsp:getProperty tag

    hi,
    i am new to jsp, so i don;t know how to populate a combobox in jsp page with productid attribute from a javabean called Bid . i want to have a code to automatically populating combobox using the attribute value from javabean.
    please reply me.
    <jsp:useBean id="bidpageid" class="RFPSOFTWARE.Bid" scope="session" />
    <jsp:setProperty name="bidpageid" property="*"/>
      <table  width="50%" align="center" border="0">
       <tr>
        <td  width="30%" align="left"><h4><b><label>Date (dd/mm/yyyy) </label></b></h4> </td>
        <td><input type="text" name="date" size="11" maxlength="10" readonly="readonly" value="<jsp:getProperty name="bidpageid" property="date"/>"  > </td>
      </tr>
      <tr> <td > </td> </tr>
      <tr>
        <td  width="30%" align="left"><h4><b><label>ProductId </label></b></h4> </td>
        <td><select name="productid" tabindex="1" size="1" >
          <option  value="<jsp:getProperty name=bidpageid" />Sachin</option>
          <option value="Hello">Vishal</option>
        </select></td>
      </tr>  and the javabean for Bid is as follow :
    import java.util.Date;
    import RFPSOFTWARE.Product;
    public class Bid{
    private Product product;
    private Integer bid_id;
    private String description;
    private Date date= new Date();
    public Integer getBid_id() {
    return bid_id;
    public Date getDate() {
    return date;
    public String getDescription() {
    return description;
    public Product getProduct() {
    return product;
    public void setBid_id(Integer bid_id) {
    this.bid_id = bid_id;
    public void setDate(Date date) {
    this.date = date;
    public void setDescription(String description) {
    this.description = description;
    public void setProduct(Product product) {
    this.product = product;
    }

    No Sir,
    I think I did not explained clearly.what I try to say is I dont want to use JSTL.I am using only Scriptlets only.I can able to receive the values from the database to the resultset.But I could not populate it in Combobox.
    My code is :
    <tr>
    <td width="22%"><font color="#000000"><strong>Assign To Engineer</strong></font></td>          
    <td width="78%">
         <select NAME="Name" size="1">
    <option><%=Username%></option>
    </select> </td>
    </tr>
    in HTML
    and in Scriptlets:
    ps1 = con.prepareStatement
              ("SELECT Username FROM Users");
              rs2=ps1.executeQuery();
              System.out.println("SECOND Succesfully Executed");
              while(rs2.next())
                   System.out.println("Coming inside rs2.next loop to process");
                   Username=rs2.getString("Username");
                   System.out.println("Success");
                   System.out.println("The value retrieved from UsersTable Username is:"+Username);
    In the server(Jboss console) I can able to display the username but I could not populate it in the Combobox .
    Can you now suggest some changes in my code,Please..
    Thanks a lot
    With kind Regds
    Satheesh

  • jsp:getProperty.... in a taglib-tag ???

    Hi !
    I have taglib where I have defined a lots of classes and one of them I have a attribute who should be dynamic. I have tryed this:
    <easyTagz:submit iteration='<jsp:getProperty name='submission' property='maxCount'/>' />
    but it dosen`t seem to work....
    Any suggestion :-)

    Dosen`t seem to work, have tryed and gets this error message:
    org.apache.jasper.JasperException: Unable to compile class for JSP
         at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:567)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:177)
    Any suggestion ???

  • Jsp:getProperty in tag attributes

    Hii....
    I have a custom tag that displays some information based on an attribute of the tag. I want to set information from a bean to the attribute using the jsp:getProperty tag...
    I want to do something like.......
    <mytagprefix:MyTag attribute1='<jsp:getProperty id="myID" property="name"/>' />
    If I do it right now I am getting the string <jsp:getProperty id="myID" property="name"/> inside the my TAG.
    any help will be appreciated.
    sanjay.

    I'm a bit rusty on custom tags, so maybe this isn't the best solution, but until you find a better one you can try '<%= myID.getName() %>' as the attribute.

  • Regarding jsp:getProperty

    hi
    i have a bean. I am setting the values of the bean and setting that bean as an attribute in the session.
    In another jsp i am able to access the bean using
    <jsp:getProperty name=".." property="..">
    Here the name is the same as the attribute name.
    But here i am not using <jsp:useBean /> tag.
    I have read some where that <jsp:getProperty> or <jsp:setProperty> should be used with the <jsp:useBean> tag.
    Please correct me where i am wrong?

    I too read the same.
    But i done an example on my local machine and i am able to access the <jsp:getProperty> without <jsp:useBean>
    Consider Testbean.jsp
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <HEAD>
    <LINK href="theme/Master.css" rel="stylesheet" type="text/css">
    <TITLE>TestBean.jsp</TITLE>
    </HEAD>
    <BODY>
    <%
    InfoBean infoBean = new InfoBean();
    infoBean.setFullname("Macro");
    infoBean.setAge("23");
    infoBean.setOccupation("employee");
    infoBean.setSex("F");
    infoBean.setQualification("B-Tech");
    session.setAttribute("InfoBeanObj",infoBean);
    %>
    <jsp:forward page = "TestBeanForward.jsp"/>
    </BODY>
    </HTML>
    The TestBeanForward.jsp is
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <HEAD>
    <LINK href="theme/Master.css" rel="stylesheet" type="text/css">
    <TITLE>TestBeanForward.jsp</TITLE>
    </HEAD>
    <BODY>
    <jsp:getProperty name="InfoBeanObj" property="fullname"/>
    <jsp:getProperty name="InfoBeanObj" property="age"/>
    <jsp:getProperty name="InfoBeanObj" property="occupation"/>
    <jsp:getProperty name="InfoBeanObj" property="sex"/>
    <jsp:getProperty name="InfoBeanObj" property="qualification"/>
    </BODY>
    </HTML>
    I ran TestBean.jsp on server and i am able to print all the values onthe browser

  • Combining jsp getProperty with HTML EMBED

    Hi, Just a quick question, I have a couple of JSP/HTML books and I can't find a way of achieving this;
    basically I have a webpage that embeds a VRML file like so
    <EMBED SRC="/VRML/stair.WRL"
    TYPE="model/vrml"
    WIDTH="300"
    HEIGHT="300"
    VRML_SPLASHSCREEN="TRUE"
    VRML_DASHBOARD="TRUE"
    VRML_BACKGROUND_COLOR="#0066CC"
    CONTEXTMENU="TRUE"
    >
    This works fine, the problem is that I now have a servlet that dynamically generates the VRML file to be displayed, so I need a way of inserting this variable into the EMBED header, how do I do this?
    If it can't be done with JSP etc then how about a JavaScript solution?
    Anyway, ive tried a few things and Im out of ideas
    Cheers
    PS, the current JSP property finder;
    <jsp:useBean id="vrmlFileFinder"
         type="legato.VRMLBean"
         scope="request" />
    <jsp:getProperty name="vrmlFileFinder" property="fileName" />

    There are two issues here
    1 - generating the WRL file (from your servlet)
    2 - generating the EMBED tag in the HTML/JSP page
    These are two different requests to the web server.
    1- generating the WRL file:
    You say you have a servlet which generates the VRML code?
    Does it generate it to file, or output it directly?
    If it outputs it directly, just point the src of the tag to be your servlet
    ie
    <EMBED SRC= "/servlet/VRMLServlet"...
    This will invoke your servlet, and return the code to the browser. (ie as long as the servlet sends it a WRL text format, it can't tell the difference)
    2 - generating the EMBED tag:
    If you want to dynamically choose which file to include, then JSP would do it like this:
    <jsp:useBean id="vrmlFileFinder" type="legato.VRMLBean" scope="request" />
    <EMBED SRC="<jsp:getProperty name="vrmlFileFinder" property="fileName" />"...
    Remember that the JSP code gets executed first, so if the property evaluates to "/VRML/stair.WRL" all the browser will see is
    <EMBED SRC="/VRML/stair.WRL" - it doesn't see the JSP code at all.
    Hope this helps.
    Cheers,
    evnafets

  • Help with JSP:GetProperty Tag

    Howdy all,
    I have a
    <jsp:getProperty name='input' property='code01'/>
    tag and would like to be able to put a variable in the property field so that I can increment from code01 to code02 to code 03 by concatenating strings
    Is this possible?

    Thanks for your input on the forum, but I tried with no sucess to put it into action:
    <% String colname="code02"; %>
    <jsp:getProperty name='Input' property='<%=colname%>' />
    Produced this:
    Internal Servlet Error:
    org.apache.jasper.JasperException: Cannot find any information on property '' in a bean of type 'com.infomed.InputBean'
         at org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:616)
         at org.apache.jasper.compiler.GetPropertyGenerator.generate(GetPropertyGenerator.java:101)
         at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.generate(JspParseEventListener.java:771)
         at org.apache.jasper.compiler.JspParseEventListener.generateAll(JspParseEventListener.java:220)
         at org.apache.jasper.compiler.JspParseEventListener.endPageProcessing(JspParseEventListener.java:175)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:210)
         at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:612)
         at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
         at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:542)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:258)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:268)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
         at org.apache.tomcat.core.Handler.service(Handler.java:287)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
         at java.lang.Thread.run(Thread.java:484)
    Any Help you can give would be greatly appreciated, what I need to do is cycle through code01, code02....code15
    and use the string to do it, but use a counter integer to create the string, ie..'code0' + i and then use the sting to access
    on of the member properties in the been...(Code01, Code02) ertc.

  • How come property attribute of jsp:getProperty  knows which method to call

    Hello friends,
    I could not understand How come property attribute of <jsp:getProperty knows which method to call
    <jsp:useBean id="test" class="BeanTest.testing" scope="page" />
    <jsp:getProperty name="test" property="name" />
    there is no method "name" in testing.class file
    if u see the existing examples "date" given in TOMCAT , it is using many <jsp:getProperty tag, but the property name is not equal to the method method name in the Bean file
    thanks,

    First do you know what a
    bean property sheet is?
    If not say so.
    Second, to your question
    The Java Runtime Environment (JRE) uses introspection to identify the appropriate get() or set() methods of that bean. What is introspection?
    Introspection is a process that allows the class to expose its accessable variables and methods and allows other classes to see what they can do with that class when requested. Eg:
    public class MyBean{
    private String someValue = null;
    public MyBean(){
    someValue = "Some String Value";
    //Introspection will reveal this method
    public String getSomeValue(){
    return someValue;
    } and
    <jsp:getProperty name="...." property="someValue" />
    will call the getSomeValue() method

  • Formatting fonts within jsp:getProperty tag????

    I'd diplaying a piece of information on one of my pages using the jsp:getProperty tag.... there seems to be no way I can effect the display of the property with the font/color that I want - when I look at the resulting HTML code, I see that this tag has created a new HTML table specifying the class "inFieldSet" (a CSS class I presume, and which I also presume if overriding my desired font/color settings). Is there a way to make the page display the property using the font/color that I want without writing a custom tag?
    Scott

    All the JSP getProperty tag does, is get a string returning the value of a property. It would not apply any formatting to your page.
    I would take a look at the "getter" for this property to see what value it is returning.
    Most probably it is returning a chunk of preformatted html.

  • Using jsp:getProperty ... inside a scriptlet

    When I use the following line in a jsp file,
    <% boolean userExists=<jsp:getProperty name="xxx" property="exist/> %>
    it gives an error saying that a term is missing, when I try to load this page. Any help is appreciated.
    Thanks,
    Nalini

    Don't put the bean in the servlet context but use the HttpSession
    session.setAttribute("xxx", loginBean);
    in the JSP retrieve the bean by
    <jsp:useBean id="xxx"
    scope="session"
    class="package.LoginBean" />
    Where id = the name of the attribute in the session
    class = the full package name of the bean.
    Or
    LoginBean myBean = (LoginBean) session.getAttribute("xxx");
    Don't forget the import
    <%@ page import="package.LoginBean" %>

  • Struts, JSP 1.1 spec and WLS 5.1 - issue with useBean and getProperty

    Hi there, I am attempting to compile a JSP page using Struts tag libraries and Weblogic 5.1 with Service Pack 9.I have defined the bean using <jsp:UseBean id="myBean" ... > and then attempt to access its methods using <jsp:getProperty name="myBean" ... > This fails with a 'myBean is not defined as bean' error. When I replace the <jsp:getProperty ...> with a scriptlet e.g. <%= myBean.getCustomerName()%> it compiles and runs just fine.I have read that the WLS server may be enforcing a strict implementation of JSP spec 1.1 which the Struts tags may not be adhering to (?).Oddly, when I start WLS without invoking the Service Pack, the error disappears and the <jsp:getProperty> works as expected!Any official reason for this strange behaviour? ... I'd like to avoid using scriptlets if possible.Thanks in advance,Rash
              

    Hi.
    The following link shows supported versions of apache:
    http://edocs.bea.com/wls/platforms/index.html#apach
    In short, WLS 5.1 does not support Apache 1.3.20. The latest supported version is
    1.3.19.
    Regards,
    Michael
    Mauricio Guerra wrote:
    Hello, i've read all the online documentation regarding the apache plug in for
    weblogic, and i haven't
    found an answer to my question:
    Does weblogic 5.1 sp8 works ok with apache 1.3.20/SSL?
    All the documentation talks mention apache 1.3.12 only...
    thanks,
    Mauricio--
    Michael Young
    Developer Relations Engineer
    BEA Support

  • Problem with login jsp

    I made a login.jsp with the help of a bean. the bean holds a string[] as a property where it stores user and pass, then those values are checked in my database, and a boolean bean property is set to true. The problem is I want to do an if statement in my JSP using that boolean, but I can't seem to get the jsp working, can anyone help me?
    I'm doing
    <%if (<jsp:getProperty name="auth" property="truth"/>) do something else something else%>
    I've also tried
    <%! boolean it = <jsp:getProperty name="auth" property="truth"/> %>
    <%if (it) do something else something else%>
    both give me compile errors.

    <jsp:getProperty name="auth" property="truth"/> is roughly equivalent to
    <% out.print(your_bean.getTruth()); %> or <%=your_bean.getTruth()%>
    Once you understand this, you'll see why your code cannot possibly work...
    Below is a simple solution to your problem.
    <jsp:useBean   class="YourBean"  id="auth"  etc.. >
    <% if auth.getTruth() {
          something; // don-t forget the semi-colon
       else {
          some other thing; // ditto
    %>If you don't want any java code inside your jsp, consult the JSTL tag lib to construct an xml-like if-else statement.

  • Problem with java beans and jsp on web logic 6.0 sp1

              HI ,
              I am using weblogic6.0 sp1.
              i have problem with jsp and java beans.
              i am using very simple java bean which stores name and email
              from a html form.
              but i am getting following errors:
              Full compiler error(s):
              D:\bea4\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp_myserver\jsp_servlet\_savename2.java:89:
              cannot resolve symbol
              symbol : class userbn
              location: class jsp_servlet._savename2
              userbn ud = (userbn) //[ /SaveName2.jsp; Line: 7]
              ^
              D:\bea4\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp_myserver\jsp_servlet\_savename2.java:89:
              cannot resolve symbol
              symbol : class userbn
              location: class jsp_servlet._savename2
              userbn ud = (userbn) //[ /SaveName2.jsp; Line: 7]
              ^
              D:\bea4\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp_myserver\jsp_servlet\_savename2.java:94:
              cannot resolve symbol
              symbol : class userbn
              location: class jsp_servlet._savename2
              ud = (userbn) java.beans.Beans.instantiate(getClass().getClassLoader(),
              "userbn"); //[ /SaveName2.jsp; Line: 7]
              ^
              3 errors
              in which directory should i place java bean source file(.java file)
              here is my jsp file:
              <%@ page language = "java" contentType = "text/html" %>
              <html>
              <head>
              <title>bean2</title>
              </head>
              <body>
              <jsp:usebean id = "ud" class = "userbn" >
              <jsp:setProperty name = "ud" property = "*" />
              </jsp:usebean>
              <ul>
              <li> name: <jsp:getProperty name = "ud" property = "name" />
              <li> email : <jsp:getProperty name = "ud" property = "email" />
              </ul>
              </body>
              <html>
              here is my bean :
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              import java.io.*;
              public class userbn implements Serializable
                   private String name ;
                   private String email;
                   public void setName(String n)
                        name = n;
                   public void setEmail(String e)
                        email = e;
                   public String getName()
                        return name;
                   public String getEmail()
                        return email;
                   public userbn(){}
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              pls help me.
              Thanks
              sravana.
              

              You realy can do it like Xiang says, but the better way is to use packages. That's
              the way BEA is designed for. If you use packages you can but your bean classes
              in every subfolder beneath Classes. Here for example we have the subfolders test
              and beans:
              You have to declare the package on top of your Bean Source Code:
              package test.beans;
              In your JSP you don't need the import code of Xiang. You only have to refer the
              path of your bean class:
              <jsp:useBean id="testBean" scope="session" class="test.beans.TestBean" />
              There are some other AppServers that only can deploy Java Beans in packages. So
              if you use packages you are always on the right side.
              ciao bernd
              "sravana" <[email protected]> wrote:
              >
              >Thank you very much Xiang Rao, It worked fine.
              >Thanks again
              >sravana.
              >
              >"Xiang Rao" <[email protected]> wrote:
              >>
              >><%@ page import="userbn" language = "java" contentType = "text/html"
              >>%> should
              >>work for you.
              >>
              >>
              >>"sravana" <[email protected]> wrote:
              >>>
              >>>HI ,
              >>>
              >>>I am using weblogic6.0 sp1.
              >>>
              >>>i have problem with jsp and java beans.
              >>>
              >>>i am using very simple java bean which stores name and email
              >>>
              >>>from a html form.
              >>>
              >>>but i am getting following errors:
              >>>
              >>>________________________________________________________________
              >>>
              >>>Full compiler error(s):
              >>>D:\bea4\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp_myserver\jsp_servlet\_savename2.java:89:
              >>>cannot resolve symbol
              >>>symbol : class userbn
              >>>location: class jsp_servlet._savename2
              >>> userbn ud = (userbn) //[ /SaveName2.jsp; Line: 7]
              >>> ^
              >>>D:\bea4\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp_myserver\jsp_servlet\_savename2.java:89:
              >>>cannot resolve symbol
              >>>symbol : class userbn
              >>>location: class jsp_servlet._savename2
              >>> userbn ud = (userbn) //[ /SaveName2.jsp; Line: 7]
              >>> ^
              >>>D:\bea4\wlserver6.0sp1\config\mydomain\applications\DefaultWebApp_myserver\WEB-INF\_tmp_war_myserver_myserver_DefaultWebApp_myserver\jsp_servlet\_savename2.java:94:
              >>>cannot resolve symbol
              >>>symbol : class userbn
              >>>location: class jsp_servlet._savename2
              >>> ud = (userbn) java.beans.Beans.instantiate(getClass().getClassLoader(),
              >>>"userbn"); //[ /SaveName2.jsp; Line: 7]
              >>> ^
              >>>3 errors
              >>>
              >>>____________________________________________________________
              >>>
              >>>in which directory should i place java bean source file(.java file)
              >>>
              >>>here is my jsp file:
              >>>--------------------------------------------------------
              >>>
              >>><%@ page language = "java" contentType = "text/html" %>
              >>><html>
              >>><head>
              >>><title>bean2</title>
              >>></head>
              >>><body>
              >>><jsp:usebean id = "ud" class = "userbn" >
              >>><jsp:setProperty name = "ud" property = "*" />
              >>></jsp:usebean>
              >>><ul>
              >>><li> name: <jsp:getProperty name = "ud" property = "name" />
              >>><li> email : <jsp:getProperty name = "ud" property = "email" />
              >>></ul>
              >>></body>
              >>><html>
              >>>
              >>>-------------------------------------------------------------
              >>>
              >>>here is my bean :
              >>>
              >>>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              >>>
              >>>import java.io.*;
              >>>
              >>>public class userbn implements Serializable
              >>>{
              >>>
              >>>     private String name ;
              >>>
              >>>     private String email;
              >>>
              >>>     public void setName(String n)
              >>>     {
              >>>
              >>>          name = n;
              >>>     }
              >>>
              >>>     public void setEmail(String e)
              >>>     {
              >>>
              >>>          email = e;
              >>>     }
              >>>
              >>>     public String getName()
              >>>     {
              >>>
              >>>          return name;
              >>>     }
              >>>
              >>>     public String getEmail()
              >>>     {
              >>>
              >>>          return email;
              >>>     }
              >>>
              >>>     public userbn(){}
              >>>}
              >>>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              >>>
              >>>pls help me.
              >>>Thanks
              >>>sravana.
              >>>
              >>
              >
              

  • JSP form values lost upon servlet request (RequestDispatcher)

    Hello,
    I have a query screen (jsp) that calls a servlet and gets results. However, although the results or errors display just fine (I do a setAttribute for them), I lose the initial values in the query form (values that the user input - which are stored in the request object). Shouldn't those values be maintained and displayed, since I'm using the RequestDispatcher and thus, I should have the same request object? Thank you, C Turner
    *****My JSP (the related code)*****
    <jsp:useBean id="form" class="com.foo.ActivityBean" scope="session">
    <jsp:setProperty name="form" property="*"
    </jsp:useBean>
    <HTML>
    <BODY>
    <FORM ACTION="ActivityFormHandler" METHOD="POST">
    <P><B>From Date</B>
    <INPUT TYPE="TEXT" NAME="fromDate" SIZE="9" VALUE="<jsp:getProperty name="form" property="fromDate"/>">
    <P><B>To Date</B>
    <INPUT TYPE="TEXT" NAME="fromDate" SIZE="9" VALUE="<jsp:getProperty name="form" property="toDate"/>">
    *****Java from my HttpServlet, ActivityFormHandler (acting as a formhandler)*****
    if (errors.size() == 0) {
    ActivityBean myActivityBean = new ActivityBean();
    myActivityBean.setBeanQueryValues(acctNumber, department, fromDate, toDate);
    Vector resultsVector = null;
    try {
    resultsVector = myActivityBean.executeQuery();
    } catch (CreateException ce) {
    errors.add("There was a problem retrieving the requested data from the database.");
    request.setAttribute("results", resultsVector);
    } else {
    //Data is not okay.
    String[] errorArray = (String[])errors.toArray(new String[errors.size()]);
    request.setAttribute("errors", errorArray);
    RequestDispatcher rd;
    rd = getServletContext().getRequestDispatcher("/public_html/ActivityQuery.jsp");
    //rd.forward(request, response);
    rd.include(request, response);

    For those interested in my question, here's what I figured out.
    Instead of:
    <INPUT TYPE="TEXT" NAME="fromDate" SIZE="9" VALUE="<jsp:getProperty name="form" property="fromDate"/>">
    Use:
    <INPUT TYPE="TEXT" NAME="fromDate" SIZE="9" VALUE="<%out.print(request.getParameter("fromDate"));%>">
    This allows the input field to persist the query value instead of blanking it out when the results are displayed. -ct

  • Please!!!!!!   How can i add rows in html table dynamically [use jsp,bean]

    hello, i am a fresher in jsp. i want to add new rows in html table dynamically.In my coding, just only shows in one row . please help my problem with correct coding and i don't want to use database. Thanks ...............!
    Here is my coding-------------------
    ---------------- form.jsp --------------------->
    <%@ page import="java.util.*,newtest1.Validation" %>
    <jsp:useBean id="mybean" scope="page" class="newtest1.Validation" />
    <jsp:setProperty name="mybean" property="name" param="name" />
    <jsp:setProperty name="mybean" property="age" param="age" />
    <% s[i][j] %>
    <html>
    <head><title>Form</title></head>
    <body>
    <form method="get">
    <table border="0" width="700">
    <tr>
    <td width="150" align="right">Name</td>
    <td width="550" align="left"><input type="text" name="name" size="35"></td>
    </tr>
    <tr>
    <td width="150" align="right">Age</td>
    <td width="550" align="left"><input type="text" name="age" size="35"></td>
    </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="5">
    <tr><td> </td></tr>
    <tr><td><input type="submit" name="submit" value="ADD"></td></tr>
    <tr><td> </td></tr>
    <tr><td width="100%" align="center" border=1>
    <% int count=mybean.getStart();
    for(int i=count; i<count+1; i++) { %>
    <tr>
    <td><jsp:getProperty name="mybean" property="name" /></td>
    <td><jsp:getProperty name="mybean" property="age" /></td>
    <td><%= count %></td>
    <% count+=1; %>
    </tr>
    <% } %></td></tr>
    </table>
    </form>
    </body>
    </html>
    ----------------- Validation.java ----------------->
    package newtest1;
    import java.util.*;
    public class Validation {
    private String name;
    private String age;
    static int start=0;
    public Validation() {    name=null;
    age=null;
    ++start;}
    public void setName(String username) { if(username!="")
    name=username;
    public String getName() { return name;  }
    public void setAge(String userage) {  if (age!="")
    {age=userage;}
    public String getAge() {  return age;   }
    public int getStart() {
    return start; }

    Hi, Do you mean to say,
    You have an HTML page in which you have a text field and an add button. If you enter anything in that text field and click on Add button the text field contents should be displayed in the same HTML page and you should be able to go on entering new values into the text field and you should be able to retain and display all the previously entered values..
    and finally the list of added items are not stored in the database..
    If this is the case
    i. Your html form should be submitted to the same page.
    ii. You need to have a Vector which holds the entered values.
    iii. Bind the vector object to the request object and collect the same vector object from the request and display its contents...
    I think this would help...

Maybe you are looking for

  • IMovie 6 and general advice

    Amateur iMovie user (but not bad at it!), some general advice requested... 1. Is iMovie HD 6 worth buying (seems like there's a bit of grief associated with it), or can you get the same effects and titles etc with a 3-D party plugin to iMovie 5? I on

  • Firefox cannot open a certain website on my laptop but on my pc it can

    I am trying to access channelsurfing.net but I get this error; The connection has timed out The server at channelsurfing.net is taking too long to respond. * The site could be temporarily unavailable or too busy. Try again in a few moments. * If you

  • Spreadsheet structure - complex cost calculation

    I am trying to set up a semi-automatic spreadsheet that will help me prepare quotes for building work. I would appreciate any advice on the best set up that would for this and possible functions I would need to use to make it work. I tried finding a

  • External drive troubles

    Dear friends I got an external case branded as SPQ IPS series. It is Firewire 400, 800, USB2 and eSATA compatible with a 1.5TB WD green caviar that I installed and many troubles with it. I checked the case with all the ports except the eSATA port. Th

  • Oracle 9i Client Software On Windows 8 64 bit

    Hi Guys, How to Install Oracle 9i client software on Windows 8 64bit? Please help on this one. Thanks in advance.