Prepopulate a form in JSP

Hello, I would like to prepopulate the text box below(in a jsp) so that instead of just showing the lastName of the user, it shows the full name of the user.
<%!
String lastName = "a";
String firstName = "b";
%>
<input type="text"
     readonly="true"
     name="name"
     id="name"
     size="60"
        value=<%out.println(lastName);%>
/>So far the text box will only contain "a". However, I would really like it to contain "ab", through concatenation. However, a simple out.println(lastName + " " + firstName), doesn't work here.

just write
value='<%=lastName)%> in your html tag values place

Similar Messages

  • How to submit a form in jsp from tag handler class

    I have a form in jsp.I created some more links in the tag handler class.Based on the link we click form action will take place.Now how can i submit the form in tag handler class for the links i created in that class.

    I have a form in jsp.I created some more links in the tag handler class.Based on the link we click form action will take place.Now how can i submit the form in tag handler class for the links i created in that class.

  • How to create a form with jsp

    I want to create an HTML form using jsp.
    It has a couple of selection boxes. The options for the selection box needs to be read from a file.
    As I understand it can create the form in HTML. And somhow uses jsp to read a file on the server get, the data and create selection box. I can have a class on the server side that does the actual read - forexample
    SelData.class.
    Would appreciate it if some one can outline how this is done.
    - thanks

    * Pass the data used to populate the select options to the JSP page in the form of a bean.
    * In the JSP page, iterate through the bean, using the data to "fill in" the attributes and body of the option tag.
    This tutorial should help a great deal with these concepts: http://java.sun.com/webservices/docs/1.1/tutorial/doc/JSPIntro.html#wp69778

  • Forms to JSP conversion

    Hi all,
    I have some forms developed in Oracle 9i forms builder.
    I want to convert them in JSP.
    Can I do this by using JHeadStart?
    I have downloaded JHeadStart 10G.
    But I can not use it with JDeveloper 9i
    What else can I use for converting 9i forms to JSP???
    Thanks in advance.
    Reagards,
    MK

    I should read http://www.oracle.com/technology/products/forms/htdocs/10g/FormsJavaSOD.html first of all.
    Regards
    Grant Ronald
    Forms Product Management

  • SOAP XML Response in the form of JSP

    Hi,
    I am using a command in Websphere Commerce(WC) as "WebServices Provider " .For new users command is WC specific java program which takes input and throws back the result to the calling program.
    when a client sends a SOAP xml request to WC WebService Command,it sends back the SOAP XML response in the form of JSP to client.The Client is in Microsoft .Net language.
    My Question is:
    1)How the client is interpreting the SOAP XML response in JSP.
    2)Since the client being a .Net provider,to understand this response,he has to make any extra
    configuration ???
    Can somebody in the forum can help me in this regard.
    Thanks
    Mike

    Hi Mike1999 ,
    I am assigned with one project that is based on SOAP,I dont know abc of this technology.How the events are handled by SOAP....Etc Etc....
    Just eloberate What is ment by SOAP.Why it is used.

  • Can we call a workflow form a JSP and/or form a Java Class?

    Is it possible to call a workflow form a JSP and/or form a Java Class?

    Below is some xpress code I wrote once, used to dynamically lauch workflows from within a workflow. Since it basically uses java classes, you reuse these in your java program or jsp:
    - create a new generic object
    - call the setId, put, ... methods on it
    - set the input variables for the workflow by putting them into the generic object
    - call the checkinView method on a LighthouseContext object which launches your workflow.
    If all you need is starting a workflow from a jsp, you might also want to take a look at the tasks/taskLaunch.jsp jsp. This is an out of the box jsp which allows launching of tasks. If I remember correctly you have to give an url parameter which specificies the name of task you want to start: tasks/taskLaunch.jsp?id=<workflow-name>
    - Robin
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE TaskDefinition PUBLIC 'waveset.dtd' 'waveset.dtd'>
    <TaskDefinition name="MVG_TD_LaunchWorkflow" taskType="Workflow" executor="com.waveset.workflow.WorkflowExecutor" suspendable="true" syncControlAllowed="true" execMode="sync" execLimit="0" resultLimit="0" resultOption="delete" visibility="runschedule" progressInterval="0">
         <Extension>
              <WFProcess name="MVG_TD_LaunchWorkflow">
                   <Variable name="workflowName" input="true"/>
                   <Variable name="taskInstanceName" input="true"/>
                   <Variable name="inputs" input="true"/>
                   <Variable name="processView"/>
                   <Activity name="start">
                        <Transition to="createProcessView"/>
                   </Activity>
                   <Activity name="createProcessView">
                        <Action>
                             <block trace="true">
                                  <set name="processView">
                                       <new class="com.waveset.object.GenericObject"/>
                                  </set>
                                  <invoke name="setId">
                                       <ref>processView</ref>
                                       <s>ProcessViewer</s>
                                  </invoke>
                                  <invoke name="put">
                                       <ref>processView</ref>
                                       <s>task.process</s>
                                       <ref>workflowName</ref>
                                  </invoke>
                                  <invoke name="put">
                                       <ref>processView</ref>
                                       <s>task.taskName</s>
                                       <ref>taskInstanceName</ref>
                                  </invoke>
                                  <if>
                                       <notnull>
                                            <ref>inputs</ref>
                                       </notnull>
                                       <then>
                                            <invoke name="assimilate">
                                                 <ref>processView</ref>
                                                 <ref>inputs</ref>
                                            </invoke>
                                       </then>
                                  </if>          
                             </block>
                        </Action>
                        <Transition to="checkInProcessView"/>
                   </Activity>
                   <Activity name="checkInProcessView">
                        <Action>
                             <block trace="true">
                             <invoke name="checkinView">
                                  <invoke name="getLighthouseContext">
                                       <ref>WF_CONTEXT</ref>
                                  </invoke>
                                  <ref>processView</ref>
                                  <new class="java.util.HashMap"/>
                             </invoke>
                             </block>
                        </Action>
                        <Transition to="end"/>
                   </Activity>
                   <Activity name="end"/>
              </WFProcess>
         </Extension>
         <MemberObjectGroups>
              <ObjectRef type="ObjectGroup" id="#ID#Top" name="Top"/>
         </MemberObjectGroups>
    </TaskDefinition>

  • Prepopulate process form of Disconnected Application Instance not working

    Hi All,
    I have a created a Disconnected application instance (OIM 11.1.2) and need to prepopulate Process form when this will be requested from catalog.
    Prepopulating is working but not as expected.
    Exact Situation
    1) Login to self service page and select a user
    2) from accounts tab -> click request Account
    3) Catalog page will be opened and select the disconnected application instance
    4) check out
    5) In the check out page, process form and child form are displayed(I attached child form also)
    6) "Prepopulate adapters are not populating the fields in check out page"
    7) Submit the request with blank details (blank form fields).
    8) Log out and Login as 'Xelsysadm' (By default request goes to 'XELSYSADM'). When opened the request, Here fields are prepopulated
    Required
    1) Fields should be prepopulated in check Out page, before submiting the request.So, that the requestor could view the details before submitting.
    The following are checked
    1) In the process definition (from design Console) of disconnected app instance, 'Auto save form' and 'Auto prepopulate' is checked
    Please tell me, what else could be done, to make this work
    Thanks in advance....
    Edited by: kavatam on May 30, 2013 3:21 AM

    Thanks for reply..
    I could not find "oracle.iam.request.plugins.PrePopulationAdapter" details in OIM 11.1.2 API http://docs.oracle.com/cd/E27559_01/apirefs.1112/e28159/toc.htm
    Could u please share API details, and link where I can find its details....
    praveen....

  • Calling a Workflow form changeAnswersResults.jsp

    Can we call a workflow form changeAnswersResults.jsp?
    In changeAnswers.jsp, when we click on Save or Cancel, accordingly I want to call two different workflows (may one)
    Can anyone give me example?
    Thanks

    hi,
    u can use following code
         LighthouseContext _lhSess = null;
    _lhSess = (LighthouseContext) new com.waveset.session.InternalSession();
    TaskDefinition taskDef = (TaskDefinition) lhSess.getObject(Type.TASKDEFINITION, "workflow name");
    TaskTemplate template = new TaskTemplate(taskDef);
    template.setExecMode(TaskDefinition.ExecMode.SYNC);
    template.setOwner("Configurator");
    TaskInstance task = _lhSess.runTask(template);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Get the data form the jsp page

    My question is too simple that I think I don't need to explain
    <form action="test2.jsp" method="post">
    <%
    String name="";
    name = (String)request.getAttribute("names");
    out.print(name);
    %>
    <input type="submit" value="submit">
    </form>
    How can I get the value of name on the test2.jsp ???
    (I have tried many way , but they didn't work......)

    hi,
    Sample code
    test1.jsp
    <form action="test2.jsp" method="get">
    <%
    String name="xyz";
    out.print(name);
    out.println("<input type='hidden' value='"+ name +"' name='name'>");
    %>
    <input type="submit" value="submit">
    </form>
    test2.jsp
    <%   
            out.println(request.getParameter("name"));
    %>

  • Invoking Forms from JSP and Vice versa

    Hi,
    I am in to a requirement like invoking a screen developed using Oracle Forms 6i from JSP and vice versa.
    1. Could you please anybody help to get the documents to be refered to get more idea on this?
    2. Is it possible only by Oracle ADF?
    Please help me on this.
    Thanks & Regards
    M Thiyagarajan

    Hi All,
    Thanks a lot for the clarifications.
    Actually, integration should happen between forms and JSP. Parameters need to be passed to and forth. I will go through the specified link.
    Also could you please clarify me where exactly, ADF comes into picture? or what are all the advantages when we go for ADF?
    Thanks & Regards
    M Thiyagarajan

  • FORM and JSP in the same page

    Hello All
    Is it possible to pass variable from a html textbox to a JSP? but they both are in the same page.
    For this purpose, I have a created a index.html, which contain two frames, top.html and bottom.jsp. There is a textbox in the top.html, it collects 2 variables and use form action "POST" to call bottom.jsp to display a graph.
    However after I run this page on Tomcat, it gave me error message in the bottom.html:
    The server encountered an internal error () that prevented it from fulfilling this request.
    Can anyone teach me how to solve this problem? Thanks a lot
    Viola
    index.html
    ===============================
    (FRAME) top.html
    <form action="bottom.jsp" method="post">
    <input type="text" name="apple">
    <input type="text" name="orange">
    ===============================
    (FRAME) bottom.jsp
    String apple = request.getParameter("apple");
    String orange = request.getParameter("orange");
    use those two variables to do something
    and display a graph

    The problem is that both pages are loaded @ the same time so when the getParameter gets executed the parameters are null and this is the probable cause of your error. Another problem is the action in form will cause the bottom to go into tops frame and not have anything to do with the other frame. If you want data to go from one frame to another while the user still sees them look @ DHTML, JavaScript and IFrames.
    HTH,
    J.Clancey

  • About Dynamic Form in JSP

    Hi,
    I want to create jsp page which can add/delete/modify and even move text boxes with label to one place to other.
    i found partially solution like Xform and even thru java script. But still don't know how to do that.
    Can any body have ever come across this type of form.
    please give me your valuable comments may be from there i will get some trick.
    Thanks,
    Ankur
    Edited by: joyhotfever on Sep 3, 2008 2:04 AM

    Your question is too general.
    Learn HTML. Learn Java. Learn JSP/Servlets. Learn JavaScript -if necessary.
    Then write code accordingly. Whenever you stucks while solving a technical coding problem, you're always welcome to ask it here.

  • Getting Date in the form in JSP

    Hi,
    I am working on a form created in JSP that gets the date from the user, just in case the user wants to modify the date (default is current date), i wish to provide an option for that. Is there any other way apart from using list boxes asking for day,month and year?
    My doubt is about the part - alternate for listboxes with separate options for day, month and year.
    Thanks and Regards,
    Reshma
    Message was edited by:
    ReshmaCB

    Other way is to let the user manually enter the date in desired format, e.g. yyyy-MM-dd, and use SimpleDateFormat to convert between String and Date.
    Date date = new Date(); // Today's date.
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String dateString = sdf.format(date); // 2007-05-24And the reversed way:String dateString = "2007-05-24";
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date date = sdf.parse(dateString); // Thu May 24 00:00:00 [zone] 2007Check the SimpleDateFormat API for several date format patterns.

  • Two select box in a form in JSP...Save me...Please

    Hi,
    My jsp page has one form with two different select/option. One select is fbox and another is tbox. tbox contains master values from db and fbox contanis some/few/no values from db.(It might be empty.) Now, I want to add a value from tbox to fbox. If that value is already in fbox then ALERT otherwise add in that value in fbox. Following is the code for that.
    Would somebody help me out ? I don't know what's wrong with this code. It's not working............It's kind of serious and urgent.
    function add(fbox,tbox) {
    var i = 0;
    if(fbox.value != "") {
    var no = new Option();
    for(var i=0; i < tbox.options.length; i++)
    if((fbox.value == tbox.options.value) || (fbox.value == tbox.options[i].text))
    alert("Value is already added. Select another item.");
    break;
    else
    no.value = fbox.value;
    no.text = fbox.value;
    tbox.options[tbox.options.length] = no;
    fbox.value = "";
    else
    alert("Please enter an item.");

    Hi Srinath or anybody,
    Would u pl. tell me what's wrong with following code ? Javascript prompt is not invoking....U can see/find javascript function addservice(service) in my code which is called by JSP code inside in my form...
    I am using Tomcat 3.3, Jdeveloper 3.2, IE 6.0 and Netscape 7.0.
    I am badly working on this but Javascript prompt is not working....
    Thanks for ur time and help...
    Waiting for ur reply.
    David
    <%@ page contentType="text/html;charset=WINDOWS-1252"%>
    <%@page language= "java" import= "java.sql.*,sun.jdbc.rowset.*,javax.servlet.http.*,java.lang.reflect.*,java.io.*,java.util.*,javax.servlet.*"
    errorPage="error.jsp" %>
    <jsp:useBean id="conn" class="package1.connectionBean" scope="session"/>
    <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=WINDOWS-1252">
    <META NAME="GENERATOR" CONTENT="Oracle JDeveloper">
    </HEAD><center>
    <BODY>
    <script language="javascript" SRC="FormChek.js"></script>
    <script language="javascript">
    function CheckFstock(ftock) {
    var Gooddigit = "0123456789";
         if (document.formtest.ftock.value.length > 3 )
              alert('Invalid Stock ! Please re-enter with less than equal to 3 digits.');
              return false;
         }// if ends
    function CheckPostal(postal) {
         var valid = 1;
         var GoodChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
         var Gooddigit = "0123456789";
         var Goodextrs = "- ";
         var i = 0;
         if (document.formtest.postal.value == "")
              // Return false if number is empty or length is not 7 length is not 6
              alert('Invalid Postal Code ! Please re-enter now.');
              valid = 0;
    document.formtest.postal.focus();
              return false;
         }//if ends
         else if(document.formtest.postal.value.length == 7)
              //alert (GoodChars.indexOf(document.formtest.postal.value.charAt(0)));
              for (i =0; i <= document.formtest.postal.value.length; i++)
                   //alert( i + "->"+ document.formtest.postal.value.charAt(0))
                   if ((GoodChars.indexOf(document.formtest.postal.value.charAt(0)) == -1) || (GoodChars.indexOf(document.formtest.postal.value.charAt(2)) == -1) || (GoodChars.indexOf(document.formtest.postal.value.charAt(5)) == -1))
                        alert("Not Valid Chacters in entered Postal Code! Please re-enter now.");
                        valid = 0;
    document.formtest.postal.focus();
                        return false;
                   } // if ends
                   if ((Gooddigit.indexOf(document.formtest.postal.value.charAt(1)) == -1) || (Gooddigit.indexOf(document.formtest.postal.value.charAt(4)) == -1) || (Gooddigit.indexOf(document.formtest.postal.value.charAt(6)) == -1))
                        alert("Not Valid digits in entered Postal Code! Please re-enter now.");
                        valid = 0;
    document.formtest.postal.focus();
                        return false;
                   } // if ends
                   if (Goodextrs.indexOf(document.formtest.postal.value.charAt(3)) == -1)
                        alert("Not Valid extras in entered Postal Code! Please re-enter now.");
                        valid = 0;
    document.formtest.postal.focus();
                        return false;
                   } // if ends
              } // for ends
         }// else if ends
         else if(document.formtest.postal.value.length == 6)
              for (i =0; i <= document.formtest.postal.value.length; i++)
                   if ((GoodChars.indexOf(document.formtest.postal.value.charAt(0)) == -1) || (GoodChars.indexOf(document.formtest.postal.value.charAt(2)) == -1) || (GoodChars.indexOf(document.formtest.postal.value.charAt(4)) == -1))
                        alert("Not Valid Chacters in entered Postal Code! Please re-enter now.");
                        valid = 0;
    document.formtest.postal.focus();
                        return false;
                   } // if ends
                   if ((Gooddigit.indexOf(document.formtest.postal.value.charAt(1)) == -1) && (Gooddigit.indexOf(document.formtest.postal.value.charAt(3)) == -1) && (Gooddigit.indexOf(document.formtest.postal.value.charAt(5)) == -1))
                        alert("Not Valid digits in entered Postal Code! Please re-enter now.");
                        valid = 0;
    document.formtest.postal.focus();
                        return false;
                   } // if ends
              } // for ends
         }// else if ends
         else { alert('Postalcode is not 7 or 6 charactres long ! Please  re-enter now.');
    document.formtest.postal.focus();
    }//else ends
         return valid
    }//this function ends
    function goback() {
    history.go(-1);
    function addItem(fbox,tbox)
    var boxLength = tbox.length;
    var selectedItem = document.formtest.list1.selectedIndex;
    var selectedText = fbox.options[selectedItem].text;
    var selectedValue =fbox.options[selectedItem].value;
    var j;
    var isNew = true;
    //alert('BOx Length is : ' + boxLength);
    if (boxLength != 0)
    for (j = 0; j < boxLength; j++)
    thisitem = tbox.options[j].text;
    if (thisitem == selectedText)
    isNew = false;
    alert("Selected value is already available. Please select a different item");
    break;
    if (isNew)
    newoption = new Option(selectedText, selectedValue, false, false);
    tbox.options[boxLength] = newoption;
    fbox.selectedIndex=-1;
    function remove(box) {
    if (confirm("Are you sure you want to delete. Continue?")) {
    for(var i=0; i<box.options.length; i++) {
    if(box.options.selected && box.options[i] != "") {
    box.options[i].value = "";
    box.options[i].text = "";
    BumpUp(box);
    function BumpUp(abox) {
    for(var i = 0; i < abox.options.length; i++) {
    if(abox.options[i].value == "") {
    for(var j = i; j < abox.options.length - 1; j++) {
    abox.options[j].value = abox.options[j + 1].value;
    abox.options[j].text = abox.options[j + 1].text;
    var ln = i;
    break;
    if(ln < abox.options.length) {
    abox.options.length -= 1;
    BumpUp(abox);
    function Moveup(dbox) {
    for(var i = 0; i < dbox.options.length; i++) {
    if (dbox.options[i].selected && dbox.options[i] != "" && dbox.options[i] != dbox.options[0]) {
    var tmpval = dbox.options[i].value;
    var tmpval2 = dbox.options[i].text;
    dbox.options[i].value = dbox.options[i - 1].value;
    dbox.options[i].text = dbox.options[i - 1].text
    dbox.options[i-1].value = tmpval;
    dbox.options[i-1].text = tmpval2;
    function Movedown(ebox) {
    for(var i = 0; i < ebox.options.length; i++) {
    if (ebox.options[i].selected && ebox.options[i] != "" && ebox.options[i+1] != ebox.options[ebox.options.length]) {
    var tmpval = ebox.options[i].value;
    var tmpval2 = ebox.options[i].text;
    ebox.options[i].value = ebox.options[i+1].value;
    ebox.options[i].text = ebox.options[i+1].text
    ebox.options[i+1].value = tmpval;
    ebox.options[i+1].text = tmpval2;
    function dosubmit() {
    for ( var i = 0; i < document.formtest.list2.length; i++ )
    document.formtest.list2.item(i).selected = true;
    for ( var i = 0; i < document.formtest.service.length; i++ )
    document.formtest.service.item(i).selected = true;
    function addservice(service) {
    var defaultSelected = true;
    var selected = true;
    //alert('Here');
    var input_box = prompt("Enter some text","");
    //alert(input_box);
    if(input_box != "")
    var optionName = new Option(input_box,input_box,false,false);
    var length = service.length;
    service.options[length] = optionName;
    else
    alert("Service should not be empty ! Write Something.");
    </script>
    <form name="formtest" METHOD="POST" onSubmit="dosubmit()">
    <% String sql;
    sql = "SELECT LINEID, DESCRIP from PURCHVENDOR.AUTOLINE";
    ResultSet results = conn.executeQuery(sql);
    %>
    <TABLE BORDER="1">
    <TR>
    <TD>Code/Type</TD>
    <TD><INPUT TYPE="TEXT" NAME="vcode" SIZE="38">
    <select name="tp">
    <option value="S">Standard</option>
    <option value="A">Aftermarket</option>
    </select>
    </TD>
    </TR>
    <TR>
    <TD>Vendor Name</TD>
    <TD><INPUT TYPE="TEXT" name="vname" SIZE="54"></TD>
    </TR>
    <TR>
    <TD>Contact Name</TD>
    <TD><INPUT TYPE="TEXT" name="cname" SIZE="54"></TD>
    </TR>
    <TR>
    <TD>Address</TD>
    <TD><INPUT TYPE="TEXT" name="address" SIZE="54"></TD>
    </TR>
    <TR>
    <TD>P.O.Box</TD>
    <TD><INPUT TYPE="TEXT" name="POBox" SIZE="54"></TD>
    </TR>
    <TR>
    <TD>City</TD>
    <TD><INPUT TYPE="TEXT" name="city" SIZE="54"></TD>
    </TR>
    <TR>
    <TD>Province/Postal</TD>
    <TD>
    <INPUT TYPE="TEXT" name="province" SIZE="25" onChange="checkStateCode(this)">
    <INPUT TYPE="TEXT" name="postal" SIZE="25" onChange="CheckPostal(this)"></TD>
    </TR>
    <TR>
    <TD>Phone Number</TD>
    <TD><INPUT TYPE="TEXT" NAME="pnumber" SIZE="54" onChange="checkUSPhone(this)"></TD>
    </TR>
    <TR>
    <TD>Fax Number</TD>
    <TD><INPUT TYPE="TEXT" name="fnumber" SIZE="54" onChange="checkUSPhone(this)"></TD>
    </TR>
    <TR>
    <TD>Fee Stock/Factory</TD>
    <TD><INPUT TYPE="TEXT" name="ftock" SIZE="25">
    <INPUT TYPE="TEXT" name="ffactory" SIZE="25">
    </TD>
    </TR>
    <TR>
    <TD>Prefered Vendor</TD>
    <TD><input type="radio" value="1" name="choice" Checked>Yes
    <input type="radio" value="2" name="choice">No
    </TD>
    </TR>
    <TR>
    <TD>Line Carried</TD>
    <TD><select multiple size="5" name="list1" >
    <%
    while(results.next())
    %>
    <OPTION value = "<%= results.getString("lineid")%>"><%= results.getString("lineid")%></OPTION>
    <%
    %>
    </select>
    <input type=button value="Add" onclick = "javascript:addItem(this.form.list1,this.form.list2);"</input>
    <select multiple size="5" name="list2"></select>
    <input type=button value="Delete" onclick = "javascript:remove(this.form.list2);"</input>
    </TD>
    </TR>
    <TR>
    <TD>Service</TD>
    <TD>
    <select multiple size="5" name="service"></select>
    <input type=button value="Add Service" onclick = "addservice(formtest.service);"</input>
    <input type=button value="Delete Service" onclick = "javascript:remove(this.form.service);"</input>
    </TD>
    </TR>
    </TABLE>
    <P><INPUT TYPE="SUBMIT" VALUE="Add" onClick="document.formtest.action='addvpdb.jsp';"</input>
    <INPUT TYPE="SUBMIT" VALUE="Cancel" onClick="document.formtest.action='vendormain.jsp';"</input>
    <!-- <INPUT TYPE="SUBMIT" VALUE="Cancel" onClick= "goback()"</input> -->
    </P>
    </center>
    </form>
    </BODY>
    </HTML>

  • Mysql update form  a form in jsp page

    <?xml version="1.0" encoding ="iso-8859-1"?>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <%-- set up database source --%>
    <c:if test="${empty sessionScope.mc07kpkDataSource}">
    <sql:setDataSource
    var="mc07kpkdbDataSource"
    driver="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost/mc07kpkdb"
    scope="session"
    user="mc07kpk_web"
    password="beGin+35"
    />
    </c:if>
    <%-- insert details to trader table --%>
    <c:catch var="insertDetails">
    <sql:update dataSource="${sessionscope.mc07kpkDataSource}">
    INSERT into trader (dbTraderPNumber,dbTraderPwd,dbTraderName,dbTraderEmail,dbTraderProgramme,dbTraderDOB,dbTraderPhoneNum,dbTraderDepartment)
    VALUES (?,?,?,?,?,?,?,?)
    <sql:param value="${param.txtname}"/>
    <sql:param value="${param.txtdepartment}"/>
    <sql:param value="${param.txtprogramme}"/>
    <sql:param value="${param.txtphonenum}"/>
    <sql:dateParam value="${txtdob}" type="date" />
    <sql:param value="${param.txtuserid}"/>
    <sql:param value="${param.txtpassword}"/>
    </sql:update>
    </c:catch>
    <c:if test="${!empty insertFailure}">
    <p><b> User Registration Failed</b></p>
    </c:if>
    <head>
    <title>Registeres USers Login Page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <body>
    <form action="" method="post" name="frmLogin" >
    <table border="0" align="right" cellpadding="2" cellspacing="0">
    <tr>
              <td width="64">Username:</td>
    <td width="60"><input name="txtLUserId" type="text" size="10"></td>
    </tr>
         <tr>
    <td width="64">Password:</td>
         <td width="60"><input name="txtLPassword" type="password" size="10"></td>
    </tr>
         <tr>
         <td colspan="2"align="center">
         <input name="btnLogin" type="submit" onclick="Traderhomepage.jsp">
         </td>
         </tr>
    </table>
    </form>
    <p> </p>
    <p> </p>
    <table width="1049" cellpadding="5" align="center">
    <tr>
    <td width="2378"><div align="center">
    <h2 align="center"> User Registration</h2>
    <p>Home | Register | Books For Sale | Buy Or Sell</p>
    </div></td>
    </tr>
    </table>
    <p align="center"> </p>
    <p>This website is only open to members of the De MontFort University.
    You will need a current @learner.dmu.ac.uk e-mail address in order to register.</p>
    <p> If you've already registered for one site you do not need to register again </p>
    <form action="userregistration.jsp" method="get" name="userfrm" id="form1">
    <table width="726" height="285" border="0" align="left" cellpadding="2" cellspacing="0">
    <tr>
    <td width="157" align="right" >Name:</td>
    <td width="561" ><input name="txtname" type="text" id="txtname" />
    </td>
    </tr>
    <tr>
    <td width="157" align="right" >Department</td>
    <td align="left" >
    <select name="txtdepartment" id="txtdepartment" >
    <option></option>
    <option>Faculty of Art and Design</option>
    <option>Faculty of Business and Law</option>
    <option>Faculty of Computing Sciences and Engineering</option>
    <option>Faculty of Health and Life Sciences</option>
    <option>Faculty of Humanities</option>
    </select>
    </td>
    </tr>
    <tr>
    <td align="right" >Programme</td>
    <td ><input type="text" name="txtprogramme" />
    (eg: BIS,SE) </td>
    </tr>
    <tr>
    <td align="right" >Telephone Number: </td>
    <td ><input name="txtphonenum" type="text" /></td>
    </tr>
    <tr>
    <td align="right" >Date Of Birth: </td>
    <td ><input name="txtday" type="text" size="15">(of format YYYY-MM-DD)</td></td>
    </tr>
    <tr>
    <td align="right" >Username</td>
    <td align="left" >
    <input name="txtuserid" type="text" size="15"/>
    (eg. p07269027 from [email protected])</td>
    </tr>
    <tr>
    <td align="right" >Password</td>
    <td align="left" >
    <input name="txtpassword" type="password" size="15" />
    </td>
    </tr>
    <tr>
    <td align="right" >Confirm Password </td>
    <td align="left" >
    <input name="txtpasswordconf" type="password" size="15" />
    </td>
    </tr>
    <tr>
    <td colspan="2" align="center">
    <input name="register" type="submit" value="register" />
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    please let me know the problem in updating data from the form to my database.

    userregistration.jsp ( view)
    <c:url value="/cw/router/userregistration" var="UregPgeURL" scope="page"/>
    <form action="${UregPgeURL}" method="get" >
    <div>
    <table width="726" height="285" border="0" align="left" cellpadding="2" cellspacing="0">
    <tr>
    <td width="157" align="right" >Name:</td>
    <td width="561" > <input name="txtname" type="text" value="${param.txtname}"/> </td>
    </tr>
    <c:if test="${!empty requestScope.reqInvalidUserName}">
    <c:out value="${requestScope.reqInvalidUserName}"/>
    </c:if>
    <tr>
    <td width="157" align="right" >Department</td>
    <td align="left" >
    <select name="txtdepartment" id="txtdepartment" value="${param.txtdepartment}" >
    <option></option>
    <option>Faculty of Art and Design</option>
    <option>Faculty of Business and Law</option>
    <option>Faculty of Computing Sciences and Engineering</option>
    <option>Faculty of Health and Life Sciences</option>
    <option>Faculty of Humanities</option>
    </select>
    </td>
    </tr>
    <tr>
    <td align="right" >Programme</td>
    <td ><input type="text" name="txtprogramme" value="${param.txtprogramme}" />
    (eg: BIS,SE) </td>
    </tr>
    <tr>
    <td align="right" >Telephone Number: </td>
    <td ><input name="txtphonenum" type="text" value="${param.txtphonenum}" /></td>
    </tr>
    <tr>
    <td align="right" >Date Of Birth: </td>
    <td ><input name="txtday" type="text" size="15" value="${param.txtdob}" >(of format YYYY-MM-DD)</td></tr>
    <c:if test="${!empty requestScope.reqInvalidDOB}">
    <c:out value="${requestScope.reqInvalidDOB}"/>
    </c:if>
    <tr>
    <td align="right" >Username</td>
    <td align="left" >
    <input name="txtuserid" type="text" size="15" value="${param.txtuserid}" />
    (eg. p07269027 from [email protected])</td>
    <c:if test="${!empty requestScope.reqInvalidUserId}">
    <c:out value="${requestScope.reqInvalidUserId}"/>
    </c:if>
    </tr>
    <tr>
    <td align="right" >Password</td>
    <td align="left" >
    <input name="txtpassword" type="password" size="15" value="${param.txtpassword}" />
    </td></tr>
         <c:if test="${!empty requestScope.reqInvalidPassword}">
    <c:out value="${requestScope.reqInvalidPassword}"/>
    </c:if>
    <tr>
    <td align="right" >Confirm Password </td>
    <td align="left" >
    <input name="txtpasswordconf" type="password" size="15" />
    </td>
    </tr>
    <tr>
    <td colspan="2" align="center">
    <input name="frmsubmit" type="submit" value="Register User" />
    <input type="reset" name="Reset" value="Reset" />
    </td>
    </tr>
    </table>
         <c:if test="${!empty requestScope.reqQueryErrorMessage}">
    <c:out value="${requestScope.reqQueryErrorMessage}"/>
    </c:if>
         <c:if test="${!empty requestScope.reqInvalidUpdate}">
    <c:out value="${requestScope.reqInvalidUpdate}"/>
    </c:if>
    proregistration.jsp(process page)
    <?xml version="1.0" encoding ="UTF-8"?>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <c:if test="${empty param.frmsubmit}">
    <c:set var="reqOutcome" scope="request" value=" " />
    <jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/> <%-- initial request --%>
    </c:if>
    <-- validate txtname --%>
    <c:if test="${empty param.txtname }">
    <c:set var=reqInvalidUserName" scope="request" value= "User Name Cannot Be Empty" />
    </c:if>
    <-- validate txtuserid --%>
    <c:if test="${empty param.txtuserid }">
    <c:set var=reqInvalidUserId" scope="request" value= "User ID Cannot Be Empty" />
    </c:if>
    <-- validate txtpassword--%>
    <c:if test="${empty param.txtpassword }">
    <c:set var=reqInvalidPassword" scope="request" value= "Password Cannot Be Empty" />
    </c:if>
    <-- validate txtdob --%>
    <c:if test="${empty param.txtdob }">
    <c:set var=reqInvalidDOB" scope="request" value= "Invalid Date Of Birth" />
    </c:if>
    <-- if userid invalid or username invalid --%>
    <-- redisplay form with originl typed-in data and with errors marked --%>
    <c:if test="${empty param.txtname or empty param.txtuserid }">
    <c:set var=reqOutcome" scope="request" value= "failure" />
    <jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/> <%-- failure --%>
    </c:if>
    <%-- check for query errors --%>
    <c:catch var="insertQueryError">
    <sql:update
    var="pgeRowCount"
    scope="page" >
    <%-- insert details to trader table --%>
    <c:catch var="pgeQueryError">
    <sql:update var="pgeRowCount" scope="page">
    INSERT into trader (dbTraderName,dbTraderDepartment,dbTraderProgramme,dbTraderPhoneNum ,dbTraderDOB,dbTraderPNumber,dbTraderPwd)
    VALUES (?,?,?,?,?,?,?,?)
    <sql:param value="${param.txtname}"/>
    <sql:param value="${param.txtdepartment}"/>
    <sql:param value="${param.txtprogramme}"/>
    <sql:param value="${param.txtphonenum}"/>
    <sql:dateParam value="${txtdob}" type="date" />
    <sql:param value="${param.txtuserid}"/>
    <sql:param value="${param.txtpassword}"/>
    </sql:update>
    </c:catch>
    <%-- check For query Error -- %>
    <c: if test="${not empty pgeQueryError}">
    <c:choose>
    <%-- check For duplicate record --%>
    <c:when test="${pgeQueryError.rootcause.errorCode == '1062'}">
    <c:set var="reqQueryErrorMessage" scope="request" value="Duplicate Record" />
    </c:when>
    <c:otherwise>
    <%-- database error --%>
    <c:set var="reqQueryErrorMessage" scope="request" value="Database Error" />
    </c:otherwise>
    </c:choose>
    <c:set var="reqOutcome" scope="request" value="failure" />
    <jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/> <%-- failure --%>
    </c:if>
    <%-- check For no rows returned --%>
    <c:if test="${pgeRowCount !=1}">
    <c:set var="reqInvalidUpdate" scope="request" value="*** rowCount not = 1"/>
    <c:set var="reqOutcome" scope="request" value="failure" />
    <jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/> <%-- failure --%>
    </c:if>
    <%-- Otherwise --%>
    <%-- Outcome is success --%>
    <c:set var="reqOutcome" scope="request" value="success" />
    <jsp:forward page="/WEB-INF/jsp/cwjsps/login.jsp"/> <%-- success --%>
    </c:if>
    Router.jsp (mapping URL)
    <%-- setup session if one does not exist --%>
    <%@ page session="true" %>
    <%-- set up debug variable --%>
    <c:set var="sessDebug" scope="session" value="false" />
    <%-- get pathinfo information from the request --%>
    <%-- this defines which use case has been requested --%>
    <c:set var="pgePathInfo" scope="page" value="${pageContext.request.pathInfo}" />
    <%-- uc02 : Login --%>
    <c:if test="${pageScope.pgePathInfo =='/home'}" >
    <jsp:forward page="/WEB-INF/jsp/cwjsps/home.jsp"/>
    </c:if>
    <c:if test="${pageScope.pgePathInfo =='/login'}" >
    <jsp:forward page="/WEB-INF/jsp/cwjsps/login.jsp"/>
    </c:if>
    <%-- uc01 : View Details Of Books For Sale --%>
    <c:if test="${pageScope.pgePathInfo =='/viewbooksforsale'}" >
    <jsp:forward page="/WEB-INF/jsp/cwjsps/viewbooksforsale.jsp"/>
    </c:if>
    <%-- uc01 : User registration--%>
    <c:if test="${pageScope.pgePathInfo =='/userregistration'}" >
    <jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/>
    </c:if>
    <%-- uc01 : debug --%>
    <c:if test="${pageScope.pgePathInfo =='/debug'}" >
    <jsp:forward page="/WEB-INF/jsp/cwjsps/debug.jsp"/>
    </c:if>
    <%-- otherwise --%>
    <jsp:forward page="/WEB-INF/jsp/cwjsps/home.jsp"/>
    debug.jsp
    <%-- \WEB-INF\jsp\cw\debug.jsp --%>
    <%-- debug include file --%>
    <c:if test ="${sessionScope.sessDebug == 'true'}">
    <table border="1">
    <c:forEach var="item" items="${cookie}">
    <tr>
    <td>inbound cookies</td>
    <td>${item.key}</td>
    <td>${item.value.value}</td> <%--note the .value.value--%>
    </tr>
    </c:forEach>
    <c:forEach var="item" items="${param}">
    <tr>
    <td>inbound parameter</td>
    <td>${item.key}</td>
    <td>${item.value}</td> <%--note the .value--%>
    </tr>
    </c:forEach>
    <c:forEach var="item" items="${requestScope}">
    <tr>
    <td>request scope object</td>
    <td>${item.key}</td>
    <td>${item.value.value}</td>
    </tr>
    </c:forEach>
    <c:forEach var="item" items="${sessionScope}">
    <tr>
    <td>session scope object</td>
    <td>${item.key}</td>
    <td>${item.value.value}</td>
    </tr>
    </c:forEach>
    </table>
    </c:if>
    1. cannot update mysql table with values from user registration form.
    2. if i turn the sessionScope = "true" in router.jsp i get error while accessing userregistration.jsp

Maybe you are looking for