Need Help: How to pass value from one page to another page in JSP


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Need Help: How to pass value from one page to another page in JSP

  1. #1
    Join Date
    Apr 2006
    Posts
    4

    Need Help: How to pass value from one page to another page in JSP

    Hi,

    I have problems in passing the value around in JSP. I have two JSP pages as below:

    test1.jsp
    ------------------------------------------------------------
    I try to get the vaule from my textbox by using:

    String strUser = request.getParameter ("strUserName");

    Then i print out by using: out.print(strUser); then i can get the value and put on my page (For example, i get ABC on my page).
    -------------------------------------------------------------------


    test2.jsp
    ------------------------------------------------------
    Next, i want to get the value from strUser (which mean that the one i already display on page in test1.jsp, ABC) to insert into my table by using INSERT INTO statement. Then i try by using

    String strUser1 = request.getParameter ("strUser");

    Is it possbile for me to do that? I cannot get anything to insert into my table. Then i tried out.print(strUser1); then i found that i get NULL value.

    Could you please give me some guidance?

    Thanks you very much for any advise you may give me.

    Kimsan

  2. #2
    Join Date
    Sep 2006
    Posts
    6
    can be done only if its inside the form tag..

    page:1
    ---------------------------------------------
    <form method=post action="sample.jsp">
    <input type=text name=text_pass value="hai">
    <input type=submit>
    </form>

    sample.jsp
    ----------------
    String teststring = request.getParameter("text_pass");
    out.print(teststring);

  3. #3
    Join Date
    Sep 2006
    Posts
    6
    otherwise u can use session variables which brings the value till the end of service.

Similar Threads

  1. JSP Error page not getting displayed
    By j.gohel in forum Java
    Replies: 1
    Last Post: 03-21-2006, 04:12 AM
  2. Replies: 0
    Last Post: 02-14-2006, 06:16 AM
  3. Replies: 0
    Last Post: 12-20-2005, 06:29 AM
  4. Replies: 0
    Last Post: 12-02-2005, 12:54 PM
  5. Must I compile a bean for a JSP page?
    By Alison in forum Java
    Replies: 1
    Last Post: 07-26-2000, 03:16 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center