Dispatch problem
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jianhong_Yu
Posted On:   Thursday, June 13, 2002 09:07 PM

Hi, gurus, I have a html form which only include username and password two fields. This form can be posted to a servlet (LoginServlet) to check user's authentication. It works fine, no matter password is correct or not. But now, I want to get the username and password before post the form to LoginServlet. So I write a middle jsp file named LoginProcessor.jsp. I firstly post this form to this jsp file and in this jsp file, I only get username and password from request and use dispatcher to dispatch the request to LoginServlet. However, when I input correct username and password, it also works fine, but when I input incorrect username or password, it will give me an String "IndexOutofBound" exception (curious). But there is no such   More>>

Hi, gurus,

I have a html form which only include username and password two fields. This form can be posted to a servlet (LoginServlet) to check user's authentication. It works fine, no matter password is correct or not.

But now, I want to get the username and password before post the form to LoginServlet. So I write a middle jsp file named LoginProcessor.jsp. I firstly post this form to this jsp file and in this jsp file, I only get username and password from request and use dispatcher to dispatch the request to LoginServlet. However, when I input correct username and password, it also works fine, but when I input incorrect username or password, it will give me an String "IndexOutofBound" exception (curious). But there is no such function like "substring", "trim" or else. Do you know the possible reason? I'm very appreciated for your help.

Thanks and Regards.

Jianhong

   <<Less

Re: Dispatch problem

Posted By:   Jianhong_Yu  
Posted On:   Thursday, June 13, 2002 09:25 PM

some implementation.

I write three jsp file named first.jsp, second.jsp and third.jsp, as following. And when I click "submit", it still give me "java.lang.StringIndexOutOfBoundsException", is this a bug???

****** first.jsp *********


UserName: 

Password: 





******** second.jsp *********
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
System.out.println("Username: " + username + ", Password: " + password);

RequestDispatcher dispatcher = request.getRequestDispatcher("third.jsp");
dispatcher.forward(request, response);
%>

********* third.jsp **********
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
out.println("UserName: " + username + "
");
out.println("Password: " + password + "
");

out.println("Session is " + (session == null ? "" : "not ") + "null");
%>
About | Sitemap | Contact