DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004

    JSP Input/output to html form

    I am using JSP with beans and have code that will take an input from the a html form text field, call a bean, and update an oracle database. I understand how to use the request.getParameter but what I want to do is populate the form fields, here is what I am trying to do:

    1. Enter a PO number and pull up the description.
    2. Edit the description on the form.
    3. Post the form and apply the update to the database.
    4. Repopulate the form field with the new description which can be edited again.

    An easy task in VB and elsewhere but I don't know how to make it work in JSP html. I have steps 1, 2 and 3 working fine, I just want to redisplay the new value so it can be updated again.

    This is a simple example, when finished it will show all the lines that go with a PO.

    <form method="post" action="PO.jsp" name="POUpdate"
    onSubmit="return chkFields(PO);"
    <table width="40%" bgcolor="green" valign="top" border="0" cellspacing="0" cellpadding="5">
    <table width="40%" height="5%" bgcolor="#3388ee" valign="top" border="0" cellspacing="0" cellpadding="10" style="border-collapse: collapse" bordercolor="#111111">
    <tr><td align="center"><font color="white" size="4">PO/Desc:</font></td>
    <td><input type="text" name="PO" maxlength="7" size="12"></td><td><input type="text" name="Description" maxlength="40" size="12"></td></tr>
    <tr><td colspan="2"><input type="submit" name="getDetails" value="Get details"></td>
    <td colspan="2"><input type="submit" name="updDesc" value="Update Description"></td></tr>

    <% POIn = request.getParameter("PO"); %>
    <% Desc = request.getParameter("Description"); %>

    <% // POWCon is my class that gets values and does the update
    if (POIn != null && POIn.length() !=0) {
    out.println("<br> inside if - PO value - " + POIn.length());
    out.println("desc value - " + POIn);
    } %>

    <% int i =0; // POWCon is my class that gets values and does the update

    i = Integer.parseInt(POWCon.getForecastDetailID());
    if (Desc != null && Desc.length() !=0) {
    POWCon.updatePO(Desc, i);
    } %>


  2. #2
    Join Date
    Oct 2004
    if you move your jsp code so that it is placed above the HTML code, you can just put the results into you inputs by adding a value="<%=someValue%>" to the input.

  3. #3
    Join Date
    Dec 2004
    Thanks, that did it. It is a embarassing simple solution but I didn't find it in any examples, most just show how to output somewhere else. I just have to move some things around and I will be set.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

By using this site, you agree to the Privacy Policy