• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

code help!!

 
viveksivakumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a jsp page which gets the user name and pass word , fine this works but what i need is that when the user name and pass word is false the page should not proceed further i mean the same login page should appear!!! how can i do this .help me.
 
SoonAnn Lim
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do a check at the login page. First get the username and password by request.getParameter("username") and ("password"), if this two objects are null(String usually), then present the login prompt for user to fill in the username and password. If username and password are not null, check if they are correct. If correct, you can forward the page using <jsp:forward page="your.html">, if incorrect, present login page again. Hope this help.
 
vivek sivakumar
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if the login is incorrect can i again use the jsp forward tag to display the same jsp page??? seems this does not work!!!
 
SoonAnn Lim
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These come right on top of my head.
**********************************
<%
username=request.getParameter("username");
password=request.getParameter("passowrd");
if (username==null | | password==null){
%>
<jsp:include file="login.html"/>
<%
}
else {
//do your verification here, return can be any, i prefer boolean
// boolean b=verificationMethod(username,password);
if (b){
//password match.
%>
<jsp:forward page="pageforrightuser.html"/>
<%
}
else {
%>
<jsp:include file="login.html"/>
//you may use <jsp:forward page="thispage.jsp/>, but you need some modification,not very sure, may try.
<%
}
}
%>
************************************************************
In your login.html, form action should point to this jsp page.Plese double check the syntax, i write it out on a fly. May contain some mistakes, but i think it should help you to understand logic behind the operation. Hope it helps.
[This message has been edited by SoonAnn Lim (edited August 09, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic