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 |
Can we compare two strings in java?
What is function and method in java?
what is polymorphism?
Why do we need singleton class?
class A { class B { psvm(String args[]) { } } } if the prg saved in A.java whats the o/p?
What is singleton service?
what is a thread?
can we write program without class
What are heap memory and stack memory and what are memory tables.
How to instantiate member inner class?
Why is string builder not thread safe?
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()); } }