• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp:checking if user logged in  RSS feed

 
shaz akhtar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys!
ive got a little problem!..i have got a shopping cart, once the user has added items to the shopping cart and clicks "checkout" i want to check if the user has logged in previously. If the user has not logged in i want them to be directed to the login page, if the user has logged in then it should allow them to go to the payment section.

on top of my payment form i have got:
<%
if ( request.getParameter("loginusername")==null ) {
response.sendRedirect("loginform1.html");
}
if ( request.getParameter("loginusername")!=null )

{
response.sendRedirect( "check2.jsp");
}
%>

currently i have got a loginform which is:
<HTML>
<BODY>
<CENTER><FONT size=5><B>DVD Zone</FONT></B>
<FORM name=UserRegisterForm action=userform.html method=post form><BR>
<TABLE cellSpacing=1 cellPadding=1 border=2>
<TBODY>
<TR>
<TH><B><FONT color=red>New Customer</FONT></B></TH>
<TR>
<TD>
<CENTER>Welcome to DVD Zone creating an <BR>account only takes a few
moments <BR>Click below to register!</CENTER>
<TR>
<TD>
<CENTER>
<INPUT type=submit value=Registername=registernow></CENTER></TD></TR>
<TR>
<TD></TR></TBODY></TABLE><BR><BR></FORM>
<FORM name=UserRegisterForm action=ValidateLogin3.jsp method=postform><BR>
<TABLE cellSpacing=1 cellPadding=1 border=2>
<TBODY>
<TR>
<TH><B><FONT color=red>Existing Customer</FONT></B></TH>
<TR>
<TD><B>Username:</B> <INPUT name="loginusername"> </TD></TR>
<TR>
<TD><B>Password:</B> <INPUT type=password name="loginpassword"></TD></TR>
<TR>
<TD>
<CENTER><INPUT type=submit value="LogIn" name=loginnow></CENTER>
</TD></TR></TBODY></TABLE><BR><BR></CENTER></FORM></BODY></HTML>

I am just getting a blank page at the moment, any suggestions in where i am going wrong here?

many thanks
shahnaz
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you getting the blank page, at loginform1.html or after you hit the Log In button?

Also, although this probably is not the root of your problem, in your form tag, you haveDo you really want to use a static html page as the action, or was that a typo?

Finally, you might want to consider actually using a servlet instead of just jsp pages. (Not trying to be smart, but this is the servlets forum after all!)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!