How do you pass parameters to a servlet from JSP

One query, how do you pass parameters to a servlet from JSP?
What kind of scope the JSP should have when we use forwardand backward button of the browser are used.
and can anyone clarify the statements string is immutable.

1)  When you call a Servlet from a JSP by default JSP passes request and response objects to Servlet implicitly.  So you canget all parameters in Servlet by

usingrequest.getParameter("text1");

2) String is a immutable means youcan't change the value of a String object once it is intialized.  Sincewhen you create a String it creates a String Object in Heap or Stringpool and assigns the reference of this object to a String variable.

    String str = new String("Java");

now Java is a object that iscreated in String pool.  Once if you assign some String object to this"str" reference it is lost.

When you are creating or adding some string value this String for eg.

       str =str.concat("Forum");

Here you are creating another String objectwith value  "StringForum" in String Pool and you are assigning the "str"reference to this newly created object.  Means you are loosing a oldstring

"Java" Since Strings are Immutable.

Java Tips by : Nagesh

Related:

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.