how can i cal servlet from jsp page?how can i pass
variablesfrom the jsp that servlet can access?

Answer Posted / ranjani

By using JSP forward attriputes within the html tag we can
just forward our page to servlet.or by using
response.sendRedirect()method we can call servlet page.
for example
-----------
<jsp:forward page="/relativepath/YourServlet" /> or
response.sendRedirect("http://path/YourServlet").

We can also pass the parameters in the same way to the
servlet
for example
-----------
<jsp:forward page=/relativepath/YourServlet>
<jsp:param name="name1" value="value1" />
<jsp:param name="name2" value="value2" />
</jsp:forward>
You may also pass parameters to your servlet by specifying
response.sendRedirect("http://path/YourServlet?
param1=val1").

Is This Answer Correct ?    11 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why are variables important in research?

556


Explain what access modifiers can be used for methods?

572


What is native code?

538


Is the empty set a singleton?

542


How do you sort arraylist in descending order?

578






What is the size of string?

565


What do you understand by soft reference?

586


Describe method overriding

589


What is a generic type?

564


Why charat is used in java?

544


Describe how to implement singleton design pattern in struts.

535


What is your platform’s default character encoding?

556


What is structure of java heap? What is perm gen space in heap?

544


What if I write static public void instead of public static void in java?

579


How to retrieve data from database in java using arraylist?

530