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 should I use abstract class?

798


What are the major advantages of internal iteration over external iteration?

846


Give an example of use of pointers in java class.

775


How do you check if an arraylist is not empty?

816


What does sprintf return?

828


Can we overload destructor in java?

780


Which method cannot be overridden in java?

814


Is there a sort function in java?

789


Why do people says “java is robust”?

783


Is void a type?

781


Does collectionutils isempty check for null?

1137


What are the classes of java?

751


What is a method declaration?

747


What is regex used for?

772


Can you inherit from an abstract class java?

777