jsp forward

G

gk

i have a JSP page.

i want to check whether there is user exists in the session or not

String user=(String)session.getAttribute("user");

if(user==null)
go to "/login.jsp"


How could i do this in JSP ? how could i convert "go to "/login.jsp"
in JSP code ?
 
A

Alex Hunsley

gk said:
i have a JSP page.

i want to check whether there is user exists in the session or not

String user=(String)session.getAttribute("user");

if(user==null)
go to "/login.jsp"


How could i do this in JSP ? how could i convert "go to "/login.jsp"
in JSP code ?

You're probably looking for code such as the following:

response.sendRedirect(redirectURL);

Or perhaps the action <jsp:forward>.

Why not google for more info? Google is good. Google lets you find out
useful information. If I didn't already know the answer I would google
for "jsp forward page" or "jsp redirect".
 
T

Tim B

gk said:
i have a JSP page.

i want to check whether there is user exists in the session or not

String user=(String)session.getAttribute("user");

if(user==null)
go to "/login.jsp"


How could i do this in JSP ? how could i convert "go to "/login.jsp"
in JSP code ?

<%
String user=(String)session.getAttribute("user");
if(user==null) {
%>
<jsp:forward page="/login.jsp"/>
<% } %>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top