March 2008
Intermediate to advanced
911 pages
20h 31m
English
So imagine you’re a JSP and you assume you’re being called from a request that includes a userName parameter. Since you’re counting on that parameter, you want to first check that the userName parameter isn’t null. If it’s not, no problem—finish the response. But if the userName parameter is null, you want to stop right here and turn the whole request over to something else—like a different JSP that will ask for the userName.
For now, we know we can do it with scripting:
JSP with a conditional forward (Hello.jsp)

JSP to which the request is forwarded (HandleIt.jsp)
<html><body>
We're sorry... you need to log in again.
<form action="Hello.jsp" method="get">
Name: <input name="userName" type="text">
<input name="Submit" type="submit">
</form>
</body></html>This is just a plain old page that gets the request parameter input from the user and then requests the JSP we were just on... Hello.jsp.
Read now
Unlock full access