Results 1 to 2 of 2
  1. #1
    redforce.bala is offline Member
    Join Date
    Sep 2010
    Posts
    23
    Rep Power
    0

    Smile Variables in servlet

    Hi

    I am having some variables in servlet which contains the data dynamically. I need to access the variables in several JSP.How to do it.Kindly help me.

    Thanks in advance..

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

    Default

    would session scope variables work for you?

    For example, on one jsp,
    Java Code:
    <%
    session.setAttribute("myVariable", new Double(8.4));
    %>
    and then in a different jsp,
    Java Code:
    <%
    Double theValue = (Double) session.getAttribute("myVariable");
    %>

    where in the general case, you can ususally stuff any object into the session attributes.

    Where session is the servlet session, not necessarily means logged in user.

Similar Threads

  1. Variables in a Servlet
    By krishkill in forum Java Servlet
    Replies: 3
    Last Post: 06-11-2010, 03:20 AM
  2. What are Instance variables and static variables?
    By sandeshforu in forum New To Java
    Replies: 3
    Last Post: 09-09-2009, 06:48 PM
  3. how can i link html+servlet+xml to form servlet
    By balachandarr in forum Java Servlet
    Replies: 0
    Last Post: 04-15-2009, 05:06 PM
  4. Replies: 1
    Last Post: 12-02-2008, 01:23 AM
  5. Replies: 1
    Last Post: 08-07-2007, 04: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
  •