Results 1 to 2 of 2

Thread: Servlet - JSP

  1. #1
    krishkill is offline Member
    Join Date
    May 2010
    Rep Power

    Default Servlet - JSP

    I have a servlet which gets parameter from a jsp page(x). it is stored in a variable in servlet as shown below. the servlet response is another jsp page(y). I should put the value of amp_num in the Jsp page (y).
    How should i do it? I'm trying using session.getAttribute

    HttpSession session = request.getSession(false);

    String amp_number = request.getParameter("amp1").toString();
    int amp_num = Integer.parseInt(amp_number);

    JSP Page(y):
    <input type="text" name="xyz" value="<%session.getAttribute(xyz); %>" size="20">

    I dont need to put in a textfield, its ok if i print it. Do I need to add any path like (@servlet) because how the jsp know from which servlet i'm calling the variable xyz. please help me.


  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Rep Power


    the <% %> will only evaluate the expression but not output the result value to the JSP rendered (e.g. HTML) output.

    what you probably want is


    Java Code:
    <input type="text" name="xyz" value="<%=session.getAttribute(xyz)%>" size="20">
    Note, no ; inside the <%= %> tag now too.

Similar Threads

  1. how can i link html+servlet+xml to form servlet
    By balachandarr in forum Java Servlet
    Replies: 0
    Last Post: 04-15-2009, 04:06 PM
  2. Servlet to Servlet connection through URLConnection
    By bsrjavaforum in forum Networking
    Replies: 0
    Last Post: 04-01-2009, 04:12 PM
  3. Replies: 1
    Last Post: 12-02-2008, 01:23 AM
  4. Replies: 0
    Last Post: 08-30-2008, 11:52 AM
  5. Replies: 1
    Last Post: 08-07-2007, 03:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts