Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Send and Receive Parameter

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Post Send and Receive Parameter

    Dear Experts,

    What is the best practice of sending and receiving the parameters from JSp to Servlet and vice versa

    request.getParameter
    OR
    session.setAttributes


    Any Suggestion will be appreciated


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Send and Receive Parameter

    Hello,

    I suggest you use the following.

    request.getParameter(String)
    Use this to get a request parameter value.

    request.setAttribute(String, Object)
    Use this method to add an attribute to the request before you forward it to the JSP, this way the JSP will be able to grab the attribute and use it when rendering the page.

    session.setAttribute(String, Object)
    Use this method when you want something stored for the lifetime of the session and over multiple requests. This can be useful for storing a User object for instance once a user has logged in.

    // Json

  3. The Following User Says Thank You to Json For This Useful Post:

    java_mein (May 14th, 2010)

  4. #3
    Junior Member
    Join Date
    May 2010
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs up Re: Send and Receive Parameter

    Many Thanks Json

Similar Threads

  1. Not able to receive SOAP response
    By abhisekh in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 12th, 2010, 07:20 AM
  2. Initialization parameter of servlets
    By rakesh in forum Java Servlet
    Replies: 3
    Last Post: April 13th, 2010, 03:14 AM
  3. Passing JTextField as String parameter
    By Christophe in forum Java Theory & Questions
    Replies: 3
    Last Post: April 11th, 2010, 05:32 AM
  4. [help] cant receive sms
    By ordinarypeople in forum Java ME (Mobile Edition)
    Replies: 0
    Last Post: April 4th, 2010, 02:41 PM
  5. How do you pass an Array as a Parameter?
    By Arius in forum Java Theory & Questions
    Replies: 1
    Last Post: January 23rd, 2010, 09:36 PM