• Post Reply Bookmark Topic Watch Topic
  • New Topic

strange error during jsp compilation - pls help  RSS feed

 
Subbu Aswathanarayan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i have a jsp page which redirects the user to another page using the forward method.
but i am getting the following error in one of my log files
Errors occurred during compilation: C:/Downloads/Project/Test/testing/WEB-INF/jsp/jrun__user2ejsp9.java:52:29:52:47: Error: No method named "getServletContext" was found in type "jrun__user2ejsp9". However, there is an accessible method "getServletConfig" whose name closely matches the name "getServletContext".
Here is the code from the jsp page
<%-- user.jsp modified on 07/19/2001 --%>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%
session = request.getSession(false);
boolean loggedin = servletUtils.isLoggedIn(session);
if(loggedin == false)
{
RequestDispatcher rd = getServletContext().getRequestDispatcher("/login.jsp");
if(rd != null)
rd.forward(request, response);
}
%>

I have left out the irrelevant parts of the code.
Any help in this regard would be greatly appreciated.

Subbu
 
Tim Holloway
Bartender
Posts: 18720
72
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you're missing your object there. I used request.getRequestDispatcher().
Another way of doing it might be:
if ( ! loggedin ) {
%> <jsp:forward page="/login.jsp"/> <%
}
Should result in the same net effect.
 
Subbu Aswathanarayan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim,
It works.
Subbu
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!