[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

How to solve the problem with the following error

Asked by Ananthakrishnan_K in Eclipse, MySQL Server, WebApplications

Tags: eclipse, mysql, java, jsp

Hi
   I got a problem with code which I attached below. Am getting a error like:
 type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /validateuser.jsp at line 18

15: <%
16: String userName = request.getParameter("USER_NAME");
17: String passWord = request.getParameter("PASSWORD");
18: if (idHandler.authenticate(userName, passWord)){
19: System.out.println("login is successfull");
20: //} else {
21: //response.sendRedirect("retry.jsp");


Stacktrace:
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

java.lang.NullPointerException
      com.mycompany.login.Login.authenticate(Login.java:42)
      org.apache.jsp.validateuser_jsp._jspService(validateuser_jsp.java:83)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Please help me out.
  Thanking you
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
<--------index.jsp--------->
 
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="validateuser.jsp" method="POST">
username - <input type="text" name="userName">
password - <input type="password" name="passWord">
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>
 
<----------validateuser.jsp--------->
 
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="java.util.*" %>
<%@page import="java.util.HashMap" %>
<%@page import="java.util.Collections" %>
<jsp:useBean id="idHandler" class="com.mycompany.login.Login" scope="request">
<jsp:setProperty name="idHandler" property="*"/>
</jsp:useBean>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head></head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<body>
<%
String userName = request.getParameter("USER_NAME");
String passWord = request.getParameter("PASSWORD");
if (idHandler.authenticate(userName, passWord)){
System.out.println("login is successfull");
//} else {
//response.sendRedirect("retry.jsp");
}
%>
</body>
</html>
 
<-----------Login.java--------->
package com.mycompany.login;
 
import java.sql.*;
import java.io.*;
 
public class Login {
	
 
	//default constructor
	public Login(){}
 
	//method for the catabase connection
	public Connection getConnection()
	throws IOException{
	Connection conn = null;
	try{
	Class.forName("com.mysql.jdbc.Driver");
	conn = DriverManager.getConnection(
	"jdbc:mysql:@localhost:3036:anantha",
	"root",
	"buser");
	}
	catch(SQLException e)
	{
	System.out.println("SQLException: " + e.getMessage());
	while((e = e.getNextException()) != null)
	System.out.println(e.getMessage());
	}
	catch(ClassNotFoundException e)
	{
	System.out.println("ClassNotFoundException: " + e.getMessage());
	}
	return conn;
	}
 
	//method that is called from validateuser.jsp and this checks for the authentic user and
	public boolean authenticate(String user, String pass)
	throws SQLException, IOException{
	String Username = null; 
	String Password = null;
	Login dbconn = new Login();
	Statement stmt = dbconn.getConnection().createStatement();
	String sql = "SELECT USER_NAME,PASSWORD FROM userlogin WHERE USER_NAME='" + user + "'" + "AND PASSWORD='" + pass + "'";
	ResultSet rs = stmt.executeQuery(sql);
	if(rs.next()){
	Username = rs.getString("USER_NAME");
	Password = rs.getString("PASSWORD");
	}
	if(Username != null && Password != null && user.equals(Username) && pass.equals(Password)){
	return true;
	}
	else return false;
	}
	}
[+][-]10/19/09 08:30 AM, ID: 25606092Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Eclipse, MySQL Server, WebApplications
Tags: eclipse, mysql, java, jsp
Sign Up Now!
Solution Provided By: Ananthakrishnan_K
Participating Experts: 2
Solution Grade: A
 
[+][-]09/30/09 05:33 AM, ID: 25457972Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09/30/09 05:47 AM, ID: 25458140Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/30/09 07:33 AM, ID: 25459280Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/01/09 02:41 PM, ID: 25473465Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625