2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by masijade
0

That is not a JSP question, technically, and this is the wrong forum for a JSP question, anyway, there is a JSP forum, that is an HTML question. The real question is, why would you want a form without an action? What purpose would it serve? That is just some food for thought. My advice would be to find an HTML forum.

0

O.k. i surfed and found that a login.jsp(form based Authentication) page needs some code to be entered in web.xml. I submit my code here.

<html>
<head>
<title>Enter your name and password</title>
</head>
<body bgcolor="#999966">
<p>&nbsp;</p>
<form method="POST" action="Order.jsp">
<p><font color="#800000" size="5">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Enter your company  name:</font><input type="text" name="coname" size="20"></p>
<p><font color="#800000" size="5">
Enter your password:</font><input type="password" name="password" size="20"></p>
<p><input type="submit" value="Submit" name="B1"></p>
<% String cname= request.getParameter("coname");
   String cpwd= request.getParameter("password");
   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   Connection c=DriverManager.getConnection("Jdbc:Odbc:emp");
   Statement s= c.createStatement();
   ResultSet r=s.executeQuery("select * from complog where Comp_name="+cname+" ");
   while(r.next())
      {
        String cpwd1 =r.getString(2);
        if(cpwd1.equals(cpwd))
          {
            response.sendRedirect("Order.jsp");
          }
%>
</form>
</body>
</html>

I felt I have use redirect there which is wrong.

0

Don't use scriptlets in JSP and use a Connection Pool. And you can't use a "sendRedirect" in the middle of a page anyway. A sendRedirect needs to be the entire page.

Also, form-based authentication is normally handled by the web container itself, you, normally, need only provide an html form and the connection information to the user realm.

See this and this.

Edited by masijade: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.