JSP and HTML forms

Hi, I have been trying to work out a way to label rows of a dynamic html form, which can then be referenced by jsp. The project is a uni one in which we are building an online book store. At the moment, we have made a search for out database, the resultant table's size is obviously done on how many results there are. ONce the results are up, for every book, there is a text box, the name of which is the ISBN of that particular book (unique code every book has, thus the primary key). This text box is going to be used so that the 'customers' can enter in a number, which will be how many copies of this book they want.
This jsp files needs to be referenced by another, so we can send a cookie to the user's computer with book details. unfortunately, in order to know which book, and how many, the user wants, we need to know the name of the check box from the first jsp file, which we cannot hardcode because due to the dynamic nature of the form will be different every time!
Are we going about things the wrong way, because I cant seem to work out a way to do this.
Thanks,
Alex

Regardless of how many results are returned, the name of your checkbox will always be the same... that's just the nature of a list of checkboxes. What changes is the values of each individual checkbox, which can be retrieved using
String[] booksChecked = request.getParameterValues("books")where "books" is the name of your checkbox.
If each book has a unique ID, then probably use this value as the value of the checkbox, and then you receive an array of IDs.
To dynamically handle the quantity boxes, name each textbox with the unique key plus an extra bit of text..
<input type="text" name="<%= book.ID%>qty">
Then you can retrieve the quantity for each book by using..
for(int i=0; i < booksChecked.length; i++)
  String qty = request.getParameter(booksChecked[i]+"qty");
}Hope this is what you're looking for :)

Similar Messages

  • Character Encoding for JSPs and HTML forms

    After having read loads of postings on character encoding problems I'm still puzzled about the following problem:
    I have an instance (A) of WL 8.1 SP3 on a WinXP machine and another instance (B) of WL 8.1 without any SP on a Win2K machine. The underlying Windows locale is english(US) in both cases.
    The same application deployed as a war file to these instances does not behave in the same way when it comes to displaying non-Latin1-characters like the Euro symbol: Whereas (A) shows and accepts these characters as request-parameters, (B) does not.
    Since the war file is the same (weblogic.xml, jsps and everything), the reason for this must either be the service-pack-level or some other configuration setting I overlooked.
    Any hints are appreciated!

    Try this:
    Prefrences -> Content -> Fonts & Color -> Advanced
    At the bottom, choose your Encoding.

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

  • How can I pass a variable between JSP and Role Form

    I need to pass a variable from (a copy of) applicationmodify.jsp to the IDM Role Form so that the variable is available within the Role Form at display. We've tried getAttribute and setAttribute modifying both the Role Form and the applicationmodify JSP and can get the form to the role form but not accessible but have had no other success. Has anyone had any success in doing this? Any suggestions would be appreciated.

    if by _root level you mean you're loading something into
    _level0 you can't won't be able to use the localconnection. the
    sharedobject is your only option.

  • Flash navigation and HTML forms

    Wondering if any one can help. Whenever I use an html form on
    an html page, my flash navigation will not show up. The area where
    it should be is blank and my browser status bar says that there are
    two items remaining (my flash navs). The browser stays like this
    indefinately, not completely loading the page.
    Any suggestions ?
    Thanks,
    Elise

    Thank you for reply. I appreciate it. So, if I understand
    correctly:
    I would embed the navbar.swf in all my html files. Then Each
    button would go to each html pages (Like page1.htm page2.htm
    etc...) Then I use your code in my html file right? Like each html
    file will have the following code:
    <param name="movie" value="nav.swf?frame=page2">
    Is that how it works. Sorry for not being able to your
    answer.
    Thank you very much again

  • JTextPane and HTML form

    I'd like to display html page containing simple HTML form. JTectPane renders tis form very good but i sthere any way to handle any data change/submit on such a form in JTextPane

    Hi,
    Take a look at this example
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    public class TestShowPage {
    public static void main(String args[]) { 
    JTextPane tp = new JTextPane();
    JScrollPane js = new JScrollPane();
    js.getViewport().add(tp);
    JFrame jf = new JFrame();
    jf.getContentPane().add(js);
    jf.pack();
    jf.setSize(400,500);
    jf.setVisible(true);
    try {
    URL url = new URL("http://www.globalleafs.com/Download.html" );
    tp.setPage(url);
    catch (Exception e) {
    e.printStackTrace();
    Just compile and run the programme. see the output. If you need more info of such type of programmes, check http://www.globalleafs.com/Download.html
    Uma
    Java Developer
    http://www.globalleafs.com

  • Data in .jsp or HTML form fields, to a JAVA File and DB

    Hi,
    I am new to the JAX-RS, I have a form where I fill in some details, There is a submit button towards the bottom of that form, when I click submit, it needs to do two actions:
    1) Pass the data in different fields through different variables to into a JAVA file. I am not sure on how to call a JAVA file or program's method from either .HTML or .JSP
    2) Extract the data from the fields and populate a DB through JDBC Connection
    Your help is greatly appreciated!
    Thanks,

    If you're looking for some to write the code for you, you're in the wrong place. If you've tried to write it yourself, but are stuck on an error message, logic issue, or something similar, feel free to ask a question!
    If you submit code, don't forget to use the code tags. If you submit an error message, be sure to copy the entire message and stack trace.

  • Using java to get table rows (jsp and html)?

    I was wondering if there is any way to count rows from a html-table?
    I want to know the number of rows created, just after it has been made. So that I can use this number 'for' creating my next table.
    Have got this to work by using javascript code:
              function test2()
                   if (!document.getElementsByTagName || !document.createTextNode) return;
              rows = document.getElementById('spesifikasjonsTabell').getElementsByTagName('tbody')[0].getElementsByTagName('tr');
              antallRader = rows.length;               
                   document.test.hoyde.value = antallRader;
                   return antallRader;
    , but this only generates on the clientside; which is not what I want.
    I got a webpage, that uses html and jsp. After the generation of a table - which has an unknown numbers of rows, because of several underlying tests - I'd like to retrive how many rows that was generated before I proceed with my next table.
    Is there a good workaround to this problem?
    P�l
    Message was edited by:
    paulOlsen

    Hey there, and thanks for fast response.
    Allready tried that code earlier. Works great on displaying the var 'row'-s inside, for instance, a <input type="text" or as a pup-up on a alert();
    The javascript works on the client-side, so I have no way of using that code for further testing in codes for my viewing; at least I can't think of any.
    The thing is that:
    1) I can't use an 'onClick', since the next table should be generated without any human interference.
    2) I used the same code to get the number of rows when I sat the table inside a form. But then, when calling the javascript function, I have no way to retrieve the linenumbers for use to test ON the next table.
    Since I'd have to use, say a field name <input type hidden="rows".., a method to call this very "rows" in jsp:
    <table>
    <!-- lots of rows -->
    </table>
    <%
    int numberOfRows = request.Parameter("rowcount") or what ever; here is where I need the 'number of rows'
    // let's just say int here though a String
    if(numberOfRows < 35)
    %>
    <table>
    <!-- Im including this table if the test above occurs -->
    </table>
    <%
    else
    %>
    <!-- if this occurs, then I'd like to do something else -->
    <%
    %>
    Any ideas?
    P�l
    Message was edited by:
    paulOlsen
    null

  • Lost Tomcat, its database and all JSP and HTML files

    I have mistakably uninstalled Tomcat from my machine, it removed the data I stored in the root including HTML and JSP files, I am using windows XP, Is there any way I can recover htem back, atlest the database and the JSP files? please Help

    Also a good example of why you should develop apps in a separate directory structure and then deploy the WAR file to Tomcat.
    You didn't have all your source code under Tomcat, did you?
    You weren't using a source control system like CVS?
    Oh, my. ;)
    You will from now on, I'll bet.
    %

  • JSPs and Html-Jump-Tags

    Hi,
              Does anybody know how I can make a Jump-Tag Reference while forwarding to a
              JSP ?
              e.x.:
              JSP:
              <a name="myJumpingPoint" href="...>
              Java:
              .forward(.., "myJspSite.jsp#myJumpingPoint",..);
              This doesn't work, because the forward doesn't know a site called
              myJspSite.jsp#myJumpingPoint.
              Hope you understand my problem ;o)
              thanx & bye
              

    JSP does not actually interpret the HTML like a browser and therefore does
              not allow the use of anchor tags. You should separate your myJspSite.jsp
              into separate files and include the parts that you need. Or, alternatively,
              you can use response.sendRedirect().
              Sam
              "Markus Hammer" <[email protected]> wrote in message
              news:[email protected]..
              > Hi,
              >
              > Does anybody know how I can make a Jump-Tag Reference while forwarding to
              a
              > JSP ?
              >
              > e.x.:
              >
              > JSP:
              > <a name="myJumpingPoint" href="...>
              > Java:
              > .forward(.., "myJspSite.jsp#myJumpingPoint",..);
              >
              > This doesn't work, because the forward doesn't know a site called
              > myJspSite.jsp#myJumpingPoint.
              >
              > Hope you understand my problem ;o)
              >
              > thanx & bye
              >
              >
              

  • In jdev jsp and Html is not working

    My JDevloper is showing some problem,
    when i m writing code in simple java file (class) its working.
    but when i m writing code in JSP it is getting compiled but when i m trying to run it ,it not getting,Even ocj server is getting started and the adsress is also getting generated but ,request time completes .Even i have checked the proxy setting .

    Hi,
    your question doesn't help solving the probem. What code did you write in a JSP ? Also, if you create a JSP file and simply type "hello world" into it, does it show ?
    Frank

  • Urgent :post xml for xsql difference with html form post

    Hi,
    We are developing an application to process xml request
    posted by external party. The requests arrive by
    http-post operation
    We developed and tested with an html-form.
    Now we encounter problems in testing with http-post
    The xsql page is processed correctly but
    insert only fixed text when formatting xml-data as input for
    the insert-request, string inserted is empty.
    Everything is by the book and html-forms works great.
    Is anybody else using xsql to insert xml data in the database on this version? Maybe can you help by looking into a testcase ? Issued a tar but am on terrible deadline
    so need help very soon.
    Details: HP-UX 11.11 Oracle 9.2.0.4 java1.4 ojdbc 1.4
    Tnx in advance,
    Jeroen

    Mark,
    Have an external partner which sends xml-requests.
    Have to read those, store them and process them.
    Idea is let them
    1)post the xml at a url where an xsql page is reading the xml
    2) transforming this for an insert into
    the database. The column is defined to store the complete xml-message.
    3) A trigger takes care of processing the stuff and preparing the output
    4) and a query in the xsql-page reads the output from an output table
    When developing and testing this with an html-form that posts the xml is works great.
    $ cat newclobins.xsql
    <?xml version="1.0"?>
    <page connection="demo" xmlns:xsql="urn:oracle-xsql" >
    <xsql:set-session-param name="id">
    select msgid.nextval from dual
    </xsql:set-session-param>
    <xsql:dml>
    delete cbs_msg_in where id={@id}
    </xsql:dml>
    <xsql:insert-request table="cbs_msg_in" column="id,msg" transform="cbsform_1.xsl"/>
    <data>
    <xsql:query null-indicator="yes">
    select msgid,msg from cbs_xml_out where msgid={@id}
    </xsql:query>
    </data>
    </page>
    $ cat cbsform_1.xsl
    <?xml version="1.0"?>
    <ROWSET xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0">
    <xsl:for-each select="request">
    <ROW>
    <MSG><xsl:value-of select="parameters/doc" /></MSG>
    <ID><xsl:value-of select="session/id" /></ID>
    </ROW>
    </xsl:for-each>
    </ROWSET>
    1) When using a tool like
    http://www.programmersheaven.com/articles/adrian/getpost/article.html it fails with
    No rows to modify -- the row enclosing tag missing. Specify the correct row enclosing tag.
    2) When using the commandline utility like
    xsql jeroen5.xsql posted-xml=test3.xml
    this works great when inserting plain text but not
    when inserting xml-format data into a column
    So problem 1 is why external tools like above or my partner that uses .net to do something similar gives this strange error?
    Problem nr 2 is should I stick to just the data in xml and forget about storing the xml-formatted data?
    Hope you can help because I am getting quite desparate here.
    Regards,
    Jeroen

  • Converting HTML Forms to PDF - Field Names

    When I use Adobe 8 to convert and HTML form to PDF all the field names in the resulting PDF have the crazy long names that are jumble of letters and numbers. So I always have to go back through and manually rename every field because I'm using another program to autopopulate the fields with data. Is there any way to get Acrobat to automatically name the fields in the PDF the same as they are named in the form either using the "name" or "id" properties of the HTML fields? I don't understand why this isn't the default behaviour to begin with.

    The reason this is done is due to a fundamental difference between HTML forms and Acrobat forms. In HTML forms, fields with the same name do not necessarily share the same value, whereas in Acrobat forms they do.
    In the conversion process, Acrobat gives each field a unique name, but also sets a field's mapping name to the name the field had in the original HTML form. This is so that if the PDF form is used to submit as "HTML", then the original field names will be used and any server process that is capable of dealing with the HTML form is capable of dealing with the resulting PDF form. So be aware that if you want to use your modified form to submit to a web server using the "HTML" format, the new field names that you set will not be used. What will be used are the hidden mapping names.
    Unfortunately, I don't think there's anything you can do about any of this to make it work like you want.
    George

  • Jsp and render as html a form field.

    I have a jsp with a form the fields of which are populated by some values.
    One field contains html code so the value is *<table><tr><td>...</td></tr></table>*.
    What I would like is that instead of having the text <table><tr><td>...</td></tr></table>
    to have the table rendered as html. Is that feasible?
    I use the <bean:write name="form" property="text"/> to have this value..
    Thank you...
    Juanita

    I found another solution so I will share it in case someone is facing the same problem. Actually I am using the <bean:write/> tag to get the form value.
    If in this tag I add filter="false" then if this value is an html text this text will be rendered as html.
    ...juanita

  • Problem with html:select or html:options tags using struts,jsp and tomcat

    Hi
    I'm updating a Struts-Project to a new layout and therefore rework all jsp Sites.
    I'm also using a new Folder-Structure and update therefore my struts-config file.
    My Problem now is:
    Till now, we had a select-field with a code like this:
    < html:form action="/timetableAction" method="POST">
    < table width="53%" border="0">
    < tr>
    < td>< html:radio property="dauer" value="semester"
    /></ td>
    < html:select property="semester" size="1">
    < htmlptions name="semesterList" />
    </ html:select>
    </ html:form>
    The problem now is, that whenever I use any <html:xy> tag, the tomcat server I use can not show the page, he shows just the headers of the template, but not the
    content.-jsp-File where the form would be in. He stops right in the middle of the html page, when he notices the <html:xy> tags.
    And the funny thing is, that he has no problem to show a page when there is a <html:errors> within it? Why could this be? the struts-html.tld File is well included and teh Tomcat Server shows no exceptions.
    Waiting for you answers and thanks

    Thank you, I already got the answer in another forum

Maybe you are looking for

  • Could not save the document to the repository for the following reason

    Hi, Some of the Scheduled reports are getting failed because of the following Error. Could not save the document to the repository for the following reason: [repo_proxy 30] InfoStore::ObjectExport::commit - (Helpers::InfoStore::ObjectExport::commit)

  • EREC: Differences between Delete Registration & Delete External Candidate

    Hello Experts, I am new to E-Recruitment. Can you please suggest me what are the exact differences between Delete Registration & Delete External Candidate as the first one locks his profile & the second one deletes his profile except that I don't see

  • Aperture (second) trial version

    Hi, I've downloaded the Aperture Trial a few months back and did not get much time to test it at the time. I also was a bit confused, coming from iPhoto, Aperture is at first intimidating. I use mainly iPhoto and Photoshop Elements 6 for my workflow.

  • How to contact Apple Care since the recall?

    Just my luck that I need Apple Care today of all days. You can't get through via telephone all you get is the message to call back. Need to see if I can get a new key board as the current is about half blank. Can't even get through on the support pag

  • Does FCP 4.5 have audio channel bug, and can only do 2 audio channels?

    I transferred my digibeta project with 4 audio channels (2 are Music & Effects) to an uncompressed QT at a dubbing facility. I can play the QT with all 4 channels heard on my G-5 Powermac, but when I import the QT file into FCP 4.5 (to do some re-cut