Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

help login.jsp

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my jsp file not work
please help me
-----------------------
<%@ page import="com.mehran.*,
java.sql.ResultSet"%>
<%
// Cookie.class.
Database db=new Database();
if(request.getParameter("sign")!=null)
{



String id = request.getParameter("user");
ResultSet rs=db.getTable("user","*"," where UserID= " + id);
if (rs.next())
{
String u1=(rs.getString("UserID"));
String u2=(request.getParameter("user"));
String p1=(rs.getString("Pass"));
String p2=(request.getParameter("pass"));
if((u1.equals(u2))&&(p1.equals(p2) ))
{

Cookie c = new Cookie("myCookie", "Hello My First Cookie");
response.addCookie(c);
session.setAttribute("pass",p2);
response.sendRedirect("insert.jsp");
}

else
{
%>
Your Login Is Incorrect <br>
Would You Like To <A HREF=login.jsp>Try Again</A>
<%
}
}
}
else
{

%>
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>

<form method="POST" action="login.jsp">
<p align="center">
<b><font size="5">Sign In To Site :</font></b></p>
</p>
<p align="center"><font size="4">UserName : </font>
<font size="4" color="#FFFFFF"><input type="text" name="user" size="20"></font></p>
<p align="center" dir="ltr"><font size="4">PassWord : </font>
<font size="4" color="#FFFFFF"><input type="password" name="pass" size="20"></font></p>
<p align="center">                
<input type="submit" value="Sign In" name="sign"></p>
<p align="left">You Are Not a Member ?   <a href="signup1.jsp"> Sign
Up</a> Now!</p>
<p align="center">                 
</p>
</form>

</body>

</html>
<%
}
%>
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To help people help you, you should post what the problem is (i.e. exception w/ stack trace, or something doesn't show up, or whatnot) and put your code in between UBB Code tags.

From skimming your code, you might be getting an IllegalStateException from calling response.sendRedirect() after adding a cookie to the response, but I'm not sure about that.

-Yuriy
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
let us know the problem first.
 
A wop bop a lu bob a womp bam boom. Tutti frutti ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic