Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp forward page  RSS feed

 
Chris Goh
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem.
I'm doing page that redirect users to a login page when:
session.isNew() is true....
so my code goes something like this:
<% if(session.isNew()){ %>
<jsp:forward page="login.jsp" />
<%}%>
can i use this method?
And why doesn't the url change to the login page?
if i want the url to change what should i do?
 
sridhar satuloori
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try request.sendRedirect(String url) it will changes the location in the browser.
 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
don't you lose the form parameters though with send.redirect?
 
Chris Goh
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
erm... after inserting the: request.sendRedirect(String url)
i got a error msg:
org.apache.jasper.JasperException: Unable to compile class for JSPC:\Tomcat\jakarta-tomcat-3.2.3\work\localhost_8080\_0002flogin_0002flogin_0002ejsplogin_jsp_23.java:103: Method sendRedirect(java.lang.String) not found in interface javax.servlet.http.HttpServletRequest.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should've read "response.sendRedirect()", that. I should point out that all javadoc, including the servlet javadoc, has an index. It pays to familiarise yourself with it.
- Peter
 
Chris Goh
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peter. Now It works.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!