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

Explain about method local inner classes or local inner classes in java?

0 Answers  


Can substring create new object?

0 Answers  


What is the this keyword?

0 Answers  


what are the difference between Java and .Net?

5 Answers  


What is the argument in java?

0 Answers  






How do you add an arraylist to an array in java?

0 Answers  


Can we have a try block without catch block?

0 Answers  


What are packages in java?

0 Answers  


Explain difference between final, finally and finalize?

3 Answers   Cognizant,


What is array length in java?

0 Answers  


How does callback work in java?

0 Answers  


What are data types in oop?

0 Answers  


Categories