hi all, I need to include a servlet[a basic authentication servlet which will assign a session for the authenticated user] in my JSP page to check whether the person accessing that page is authenticated. I tried to use include but i am getting error saying the servlet was not found im sure the path is correct. I tried to use <jsp:include page="" flush="true"> this doesnt throw any error but it is not authenticating the person. I appreciate any help. Thanks, Roopa
Manikandan Pattathil
Greenhorn
Joined: Feb 13, 2002
Posts: 2
posted
0
Usually the scenario explained will be handled like this. You dont have to include a JSP in Servlet. 1. Validate the login and authenticate the user. 2. If logged in forward to Success.jsp 3. Else forward to Failure.jsp You can use the sendRedirect() method in HTTPServletResponse class to navigate to the Success.jsp or Failure.jsp depending on the condition. See below from API method help. --------------------------------------------- sendRedirect public abstract void sendRedirect(String location) throws IOException Sends a temporary redirect response to the client using the specified redirect location URL. The URL must be absolute (for example, https://hostname/path/file.html). Relative URLs are not permitted here. Parameters: location - the redirect location URL Throws: IOException If an I/O error has occurred. ---------------------------------------------
john wu
Greenhorn
Joined: Nov 27, 2001
Posts: 7
posted
0
You can not include a servlet, but you can use a servlet in your jsp. there are three options for using a servlet in jsp. 1. import your servlet class, and create a instance of servlet in your jsp. 2. make your servlet as a bean of your jsp. 3. write your own tag library. hope these three cents are helpful.
tatae alvostru
Greenhorn
Joined: Jun 04, 2001
Posts: 17
posted
0
Use RequestDispatcher rd = getServletContext().getRequestDispatcher("file to include - jsp or servlet"); rs.include();
roopa sudhi
Greenhorn
Joined: Oct 31, 2001
Posts: 16
posted
0
Thanks for ur replies, I used forward,and a jsp to store the original url from where it went.so that it can come back to the same page. thanks again.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.