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



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

Answer / 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

More Core Java Interview Questions

What is the difference between jdk, jre, and jvm?

0 Answers  


What are thread safe functions?

0 Answers  


Why transient variables wont participate in serialization?

2 Answers  


What is JVM ?

4 Answers   Phantom Technologies, TCS,


System.out.println("somestring"); It will create any object or not

5 Answers   CSC,






What is string literal in java?

0 Answers  


Why does java doesnot support multiple inheritance?

5 Answers   TCS,


What is more advisable to create a thread, by implementing a Runnable interface or by extending Thread class?

5 Answers  


Why declare Main() method as a static in java ?

0 Answers   HCL,


Why scanner is used in java?

0 Answers  


Why char array is favored over string for the storage of passwords?

0 Answers  


why are wait(), notify() and notifyall() methods defined in the object class? : Java thread

0 Answers  


Categories