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

Can we compare two strings in java?

0 Answers  


What is function and method in java?

0 Answers  


what is polymorphism?

5 Answers   Zensar,


Why do we need singleton class?

0 Answers  


class A { class B { psvm(String args[]) { } } } if the prg saved in A.java whats the o/p?

7 Answers   HCL, TCS,


What is singleton service?

0 Answers  


what is a thread?

13 Answers   IBM, SunGard,


can we write program without class

6 Answers   TCS,


What are heap memory and stack memory and what are memory tables.

0 Answers   Aspiring Minds,


How to instantiate member inner class?

0 Answers  


Why is string builder not thread safe?

0 Answers  


What will be the output of the program? public class Test { public static void main(String args[]) { ArrayList<String> list = new ArrayList<String>(); list.add("2"); list.add("3"); list.add("4"); list.add("5"); System.out.println("size :"+list.size()); for(int i=0;i<list.size();i++) { list.remove(i); } System.out.println("size after:"+list.size()); } }

5 Answers   Rolta,


Categories