Results 1 to 2 of 2

Thread: Servlet - JSP

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

    Default Servlet - JSP

    Hi,
    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

    SERVLET:
    -------------------
    HttpSession session = request.getSession(false);

    String amp_number = request.getParameter("amp1").toString();
    int amp_num = Integer.parseInt(amp_number);
    session.setAttribute("xyz",lamp_num);

    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.

    Thanks,

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    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, 12: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
  •