getting value in servlet

Posted on 2004-10-21
Last Modified: 2010-04-01
   I have
       <td><%=Name%></td>(name is like java,C)
<td>select name="rating">
 <option value="<%=ratId%><%=ratname%></option>
This is also dynamic,
I want both value in servlet
  nameId  and ratId,
basically , how to send nameId because it is lable..
Thanks in advance...
Question by:Manish
    LVL 35

    Expert Comment


    Can you explain a bit more?

    > I want both value in servlet
    >  nameId  and ratId,

    what is nameId?  Do you mean "Name"?  

    Is this in a form?  Does the form post to a servlet?


    >   <option value="<%=ratId%><%=ratname%></option>

    did you mean:

     <option value="<%=ratId%>"><%=ratname%></option>


    That example JSP contains quite a few errors for such a small bit of code ;-)

    LVL 11

    Author Comment

       I m getting values from database ..
    nameId, Name
    ratId and ratingName..
    I m displaying these value like this
    <td><%=Name%></td> and rating in combbox
    <td>Rating <select name=rating>
                     <option value="<%=ratId%>"<%=ratingName%></option>
    This is in form..
       My problem is how can I get nameId in serlvet
    and corrouponing selected rating
    I m diplaying name in td ,

    LVL 35

    Accepted Solution

    again, that isn't valid HTML...

    Do you mean like this:

    <td><%=Name%></td> and rating in combbox
      <input type="hidden" name="nameId" value="<%= nameId %>">
    <td>Rating <select name=rating>
                     <option value="<%=ratId%>"><%=ratingName%></option>
    LVL 11

    Author Comment

    I want to ask where to store nameId so that I cant get it in servlet...with corrousponding selected ratId
    as these are dynamic ,means it is one or more..
    LVL 2

    Assisted Solution

    the best place is to store it is in the session :-
    <% request.getSession().setAttribute("nameId",nameId ) %>

    then when you need it in the next servlet/jsp you use :-
    <%=(String) request.getSession().setAttribute("nameId",nameId ) %>

    this way the data is stored on the server but only available to requests from the same browser. So you dont have to store the value in the page you store it in the session and its always available for that user.
    LVL 11

    Author Comment

    I stored with ratId , so I also get nameId along with
    selected ratId...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Anonabox PRO Tor & VPN Router

    PRO is the most advanced way to fortify your privacy and online anonymity by layering the Tor network with VPN services. Use both together or separately, and without needing to download software onto your devices.

    Easy CSR creation in Exchange 2007,2010 and 2013
    Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now