Results 1 to 6 of 6

Thread: session

  1. #1
    jhen is offline Member
    Join Date
    Nov 2008
    Posts
    12
    Rep Power
    0

    Default session

    what will i do to display the inputted information such as FirstName and Lastname of the user to the next page...

    for instance:

    firstname:
    lastname:

    submit button

    1 am the user and i will input my first and lastname above... then, when i will click the submit button, my inputted information will be displayed on the next page in the web...


    how will i do that if i am going to use a servlet??

    anyone plz...urgent...

  2. #2
    Join Date
    Nov 2008
    Posts
    3
    Rep Power
    0

    Default

    On which page you want to display the given inputs, take the values from previous page as -
    String name=request.getparametre("name");
    String age=request.getparametre("age");

    Now you can use variables name and age wherever you want to display them.

  3. #3
    jhen is offline Member
    Join Date
    Nov 2008
    Posts
    12
    Rep Power
    0

    Default session

    it doesn't function... still the same, it doesn't turn on the next page... i have here the codes but same result...

  4. #4
    Join Date
    Nov 2008
    Posts
    3
    Rep Power
    0

    Default

    Can you please copy your code here...

  5. #5
    jhen is offline Member
    Join Date
    Nov 2008
    Posts
    12
    Rep Power
    0

    Default session

    here is the code....

    import java.io.IOException;

    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;

    import bean.Information;


    public class Request extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
    private HttpSession session;
    private RequestDispatcher dispatcher;
    private Information bean;
    private String go;


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doPost(request, response);
    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    session=request.getSession(true);

    if (session!=null){

    bean=(Information)session.getAttribute("isBean");

    }
    if (bean!=null){
    if(request.getParameter("submit")!=null){
    bean.setFirstName("firstName");
    bean.setLastName("lastName");
    bean=(Information)session.getAttribute("isBean");
    go="Lst.jsp";
    }

    }
    else{
    Information bean=new Information();

    }
    dispatcher = request.getRequestDispatcher(go);
    dispatcher.forward(request, response);
    }
    }


    urgent... plz help me... I don't know the problem there....It has no error.. the problem is when i click the submit button, it doesn't move on the next page...:o

  6. #6
    dragonlinux is offline Member
    Join Date
    Mar 2009
    Posts
    3
    Rep Power
    0

    Default

    show your web.xml content and html page that contain submit button. maybe i can try fixed it..

Similar Threads

  1. how to create session in jsp
    By sandip_ingle21 in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 04-21-2011, 04:10 AM
  2. Session and request in JSF
    By felixtfelix in forum Web Frameworks
    Replies: 0
    Last Post: 05-08-2008, 06:10 PM
  3. session
    By jm_it04 in forum AWT / Swing
    Replies: 0
    Last Post: 03-04-2008, 12:32 PM
  4. Refresh session
    By cachi in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-07-2007, 08:52 AM
  5. Use session
    By Eric in forum Java Servlet
    Replies: 1
    Last Post: 07-05-2007, 09:34 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
  •