Solved

getting value in servlet

Posted on 2004-10-21
239 Views
Last Modified: 2010-04-01
Frds,
   I have
       <td><%=Name%></td>(name is like java,C)
<td>select name="rating">
 <option value="<%=ratId%><%=ratname%></option>
</select>
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...
Karan
0
Question by:Manish
    6 Comments
     
    LVL 35

    Expert Comment

    by:TimYates
    Errrr....

    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?

    By:

    >   <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 ;-)

    Tim
    0
     
    LVL 11

    Author Comment

    by:Manish
    Ok,
       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 ..as
    I m diplaying name in td ,




     
    0
     
    LVL 35

    Accepted Solution

    by:
    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>
                      </select>
    0
     
    LVL 11

    Author Comment

    by:Manish
    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..
    karan
    0
     
    LVL 2

    Assisted Solution

    by:siliconeagle
    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.
    0
     
    LVL 11

    Author Comment

    by:Manish
    I stored with ratId , so I also get nameId along with
    selected ratId...
    0

    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