How To redirect to another JSP ?

How To redirect to another JSP ? on button click?Also i want to execute Servlet from jsp How can i do ?Thanks
[130 byte] By [NikisinProblema] at [2007-11-27 8:06:17]
# 1

> How To redirect to another JSP ? on button click?

This makes no sense. Either on a button click, you submit a form to anywhere you like - best a servlet - or from a servlet to a JSP using the request's RequestDispatcher.

> Also i want to execute Servlet from jsp How can i do ?

Start with getting a basic understanding of either technology.

CeciNEstPasUnProgrammeura at 2007-7-12 19:48:51 > top of Java-index,Java Essentials,New To Java...
# 2
sorry that is my another question on another button ckick iwant toexecute servlet can u givem e syntax of both thanks
NikisinProblema at 2007-7-12 19:48:51 > top of Java-index,Java Essentials,New To Java...
# 3

....general solution(reusable throughout).....

Make your servlet as the main controller object. call the jsps from the servlet always(servlet is better for request handling). eg. introduce a method in jsp called : callJSP(String jspName)

Initial hit (url like index.html) will be to the servlet(through servlet mapping if needed) use a method to control all those request (generalize say processRequest(HttpRequest, HTTPResponse) )

now when you click a link on the jsp that will call this processRequest, fields in the jsp forms can be put into a cacheobject (wrapper of session object) and the required jsp can be called after that as per the logic in processrequest() and with the help of callJSP().

this logic can be used throughout the application for navigation.

or a more easier method...:):)

--index,jsp

<%

response.sendRedirect("/newIndex.jsp");

%>

<HTML>

<HEAD>

Redirecting...

</HEAD>

<BODY>

</BODY>

</HTML>

-

jSandya at 2007-7-12 19:48:51 > top of Java-index,Java Essentials,New To Java...
# 4
do NOT do that. NEVER use scriptlet code in JSP.JSTL provides mechanisms you can use instead.
jwentinga at 2007-7-12 19:48:51 > top of Java-index,Java Essentials,New To Java...