Hi..
i need to learn how to send the username and password to the database and when the user logs in it should retrieve the password from the database and authenticate if the username and password is correct.
Am using this jsp code and getting error in (Resultset line)
here i attached my connection program
<%@ page import="javax.sql.*"%>
<%!
Connection cn=null;
Statement st=null;
%>
<%
Class.forName("com.mysql.jdbc.Driver");
cn=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3307/legal_aid", "root", "123456");
out.println("Connection successfully completed...");
%>
here i attached jsp code for comparision
<%@ include file="getcon.jsp"%>
<%@ page import="java.sql.DriverManager"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.io.IOException"%>
<%@ page import="com.mysql.jdbc.Connection"%>
<%@ page import="com.mysql.jdbc.*"%>
<%@ page session="true"%>
<%!String s1,p1;
ResultSet rs=null;%>
<%s1=request.getParameter("username");
p1=request.getParameter("password");
rs=st.executeQuery("select * from registration where user_name='"+s1+"' and password='"+p1+"'");
if(rs.next())
{%>
response.sendRedirect("service_upload.html");
<%}
else
{
%>
response.sendRedirect("login.html");
<%}%>
This is am getting error
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:498)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
java.lang.NullPointerException
org.apache.jsp.legal_005faid.login_jsp._jspService(login_jsp.java:86)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
Please give me the solution for this
or else if u have any other related code send me to my email-id.
Thanking you.
madhu ms
<EMAIL SNIPPED>