How do you
pass parameters to a servlet from JSP
One query, how do you pass parameters
to a servlet from JSP?
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 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.
|