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 |
wHAT IS DEFAULT SPECIFIER IN JAVA wHAT IS DEFAULT CONSTRUCTOR IN JAVA wHAT IS DEFAULT METHOD IN JAVA
What is busy spin, and why should you use it?
java program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors.
What is arrays sort in java?
whats the diff between jsp and servlets?
What does compareto () do in java?
What will happen inside init() in servlet. my interviewer asked servlet lifecycle. i said "once servlet is loaded in to memory init() will be called which performs servlet initialization " . Again interview asked what values will be initialized . what is difference between init() and init(ServletConfig config).
2 Answers Infinite Computer Solutions, TCS,
Which sorting algorithm is in place?
Can a main method be declared final?
What are unchecked exceptions in java?
What is a class reference?
What is java jit compilers?