• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp:checking if user logged in

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!)
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic