Error

Error

1. login.java


/*
* login.java
*
* Created on September 14, 2010, 11:47 AM
*/

import java.io.*;
import java.net.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.servlet.*;
import javax.servlet.http.*;

/**
*
* @author Nicodemus
* @version
*/
public class login extends HttpServlet {


/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String a=new String("");
String b=new String("");
String query="select UserName,Passwords from users";


try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:nico;integrated security=true");
Statement stmt=con.createStatement();
stmt.executeQuery(query);
ResultSet rs=null;
rs=stmt.getResultSet();
while(rs.next())
{
a=rs.getString(1);
b=rs.getString(2);
}
rs.close();
stmt.close();
}
catch(Exception e)
{
out.println("Exception is..."+e);
}
if(a.equals(request.getParameter("user")) && b.equals(request.getParameter("password")))

{
out.println("User is Valid..<a href='Admin.jsp'>Admin Page</a>");
}
else{
out.println("Please enter correct username and password....<a href='index.jsp'>Try Again</a>");
}



/* TODO output your page here
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet login</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet login at " + request.getContextPath () + "</h1>");
out.println("</body>");
out.println("</html>");
*/
out.close();
}

// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/** Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Short description";
}
// </editor-fold>
}


2.index.jsp



<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<script>
function checkNull(field)
{
if(login.user.value == "")
{
alert("Enter the Login Name");
login.user.focus();
return false;
}
else if(login.pass.value == "" )
{
alert("Enter the Password");
login.pass.focus();
return false;
}
else
{
return true;
}
}

function focus()
{
login.user.focus();
}
</script>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login Page</title>
</head>
<body>

<body>

<form action ="login" method="post" name="login">

<p> </p>



<a title="Press To Go Back" href="login.jsp" style="text-decoration: none">
<font color="#FFFFFF" face="Bauhaus 93" size="4"><-- BACK</font></a></p>
<div align="center">
<center>
<div align="center">
<center>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#0099cc" width="51%" id="AutoNumber1" bgcolor="#0099CC" height="134">
<tr>
<td width="100%" colspan="3" height="19">
<p align="center">
<b><font face="Verdana" color="#00FF00">ADMIN LOGIN
</font></b></p>

</td>
</tr>
<tr>
<td width="30%" height="23"><font face="Verdana" size="2" color="#800080">
USER NAME</font></td>
<td width="72%" colspan="2" height="23"><font color="#800080"><input type="text" name="user" size="20" onload = 'T1.focus();'></font></td>
</tr>
<script>
focus();
</script>

<tr>
<td width="30%" height="23"><font face="Verdana" size="2" color="#800080">
PASSWORD</font></td>
<td width="72%" colspan="2" height="23"><font color="#800080"><input type="password" name="pass" size="20">
</font> </td>
</tr>

<tr>
<td width="30%" height="23"> </td>
<td width="72%" colspan="2" height="23"> </td>
</tr>
<tr>
<td width="30%" height="26"> </td>
<td width="18%" height="26">
<p align="left"><font color="#800080"><input type="submit" value="Login" name="B1" onclick = 'return checkNull();'></font></td>
<td width="54%" height="26"><font color="#800080"><input type="reset" value="Cancel" name="B2"></font></td>
</tr>
</table>

</center>
</div>
<p align="left"><font color="#008080"> </font></p>

<p align="left"><font color="#008080">
</font></p>

<p align="left"><font color="#008080">
</font></p>

</center>
</div>
</form>
</body>


<%--
This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
--%>
<%--
<c:if test="${param.sayHello}">
<!-- Let's welcome the user ${param.name} -->
Hello ${param.name}!
</c:if>
--%>

</body>
</html>



3. create table users
(
UserNAme varchar(30) not null, Passwords varchar(30) not null primary key(UserName,Passwords)
)



I tried this code but its not helping me. What I want is to login but it always shows <Please enter correct username and password>. Please help I'm a student. Thanks
View Answers









Related Tutorials/Questions & Answers:
error
error  while iam compiling iam getting expected error
Error-
Error-   Hello, I would like to know about XSD file. I try to print XML file but I am getting error SAXException-- says Content is not allowed in prolog. Please help me
Advertisements
error
error  i have 404 error in my program plz tell me yhe solution about
error
error  i have 404 error in my program plz tell me yhe solution about
error
/ServletUserEnquiryForm.shtml getting an error given below SQLException caught: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error please suggest
Error
Error  I have created ajax with php for state and city. When I change state then city will not come in dropdown list and it give me error as 'Unknown Runtime Error'. This error come only in IE browser, but in other brower
error
error  java.lang.unsupportedclassversionerror:bad major version at offset 6 how to solve this????   Hi, Please check the version of framework used and also the JDK version.ADS_TO_REPLACE_1 This type error also comes
error
error
error
error  When I deploye the example I have this message cannot Deploy HelloWorld Deployment Error for module: HelloWorld: Error occurred during deployment: Exception while deploying the app [HelloWorld
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
error!!!!!!!!!
error!!!!!!!!!   st=con.createStatement(); int a=Integer.parseInt(txttrno.getText()); String b=txttname.getText(); String c=txtfrom.getText(); String d=txtto.getText
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern
Error
Error  Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance. package...;"); // ERROR out.println(" var pattern = /^\d{3,5
error
"+it); } } this is my program i am getting an error saying cannot find symbol class stringADS
error
error  whats the error.............. import java.util.Scanner; public class g { public static void main(String[] args) { Scanner s=new Scanner(System.in); int d,x,y; System.out.println("Enter the first number
error
error
error
error
error
error message
error message  Sir i make one form facility with insert,update,delete.i want to error msg if any type of the data is missing and display in error msg which of the data is misssing
Permgen error
Permgen error  hi how can i solve permgen error
installation error
installation error  hi, m getting an error like " semicolon found in the selected path".how to resolve this error? during installation of jdk 1.6
error log
error log  hi my requirement is validate xml and xsd in java.If there is an errors then i will log error and store into error table. so plz if any one knows send code urgent. error table details-------------- Table
MAin error
MAin error  Error while running hello program in another dir rather in bin. path is already set. java -version jdk1.6.0_24 no error while compilation but @ d tym of runnin error in main class is generated Exception in thread
JSF error
JSF error  some of the users are not able to update the db. getting the error "An Error Occurred: Error calling action method of component with id CreateorManageOffer:jidjsp134312524923 Caused by: java.lang.NullPointerException
404 error
into jboss->server-> default->deploy folder it doesn't shows any error. but when i run this application by using localhost:8080/webapp ,it shows 404 error how should i slove this error
404 error
404 error  struts application having 404 error while hosting to a online server.it works fine in my local machine but dont work in virtual host.showing 404 error
Error display
Error display  I want to give a message on the screen that an error has occured...but I dont want to use alert and give pop up box...any other solution for the problem
JSP error
JSP error  what is difference between global-exception and error-page in jsp. which condition they are use
LOGIN ERROR
LOGIN ERROR  ERROR SCRIPT: LOGIN FAILED", $_SESSION['login fail']='0',}?> Ty Team
programming error
programming error  I got an error when i did the following program the prg. is to "select the name from database when the age is given for the respective name" error i got is:SQL exception please give me the solution by providing
error in driver
error in driver  i have done connection settings for oraclethin driver in netbeans ide 6.9.1. and i was able to view tables of my database.but when i am trying to access tables from my java class i was getting error
Tomcat Error:
Tomcat Error:   Hi, I am not able to start the tomcat server. If I try to start it then I am getting the below error. "coyote connector has not been started" Could some body please help me to solve the problem??? Thanks a ton
Error on example
Error on example  When I execute this program,it is throwing ArrayIndexOutOfBound exception. How can I solve this.   Post your code
404 error
404 error  i have 404 error in my addition programe of servlet how should i solve this. i'm using netbean on glassfish server
404 error
404 error  i have 404 error in my addition programe of servlet how should i solve this. i'm using netbean on glassfish server
Error here
Error here  <%@ taglib prefix="s" uri="/struts-tags" %> its giving me error as: org.apache.jasper.JasperException: File "/struts-tags... will be the cause of dis error
Java error
Java error  class WhileLoopMethod{ public static void main(String args[]){ new Hello(); } } class Hello{ int a = 5, b = 88; while(a } //it is giving compile time error .....illegal start
Java error
Java error  class WhileLoopMethod{ public static void main(String args[]){ new Hello(); } } class Hello{ int a = 5, b = 88; while(a } //it is giving compile time error .....illegal start
Error in JfreeChart
Error in JfreeChart  I am getting an error when i am using jfreechart for graph generation, that is: D:\my\linechart.java:5: package org.jfree.chart does not exist import org.jfree.chart.*;ADS_TO_REPLACE_1 what is the reason
Jcommon error
Jcommon error  hi................. what u had said i have downloaded the jar file the latest one then also its giving me same error can u tel me why... the code for bar chart and pie chart where this error will not come. and also
Error in servlets
Error in servlets  I cant execute my servlet or jsp programs. Im getting an error resource not found. I am using tomcat 6.0. I have set the path and class path correctly. My code is also correct. I have done everything but i
installation error
installation error  Error : Invalid path, "C:\Program Files\Java\jdk1.6.0\bin\javac.exe" -g -classpath "C:\Documents and Settings\Admin\My Documents" -d "C:\Documents and Settings\Admin\My Documents" "C:\Documents and Settings
installation error
installation error  Error : Invalid path, "C:\Program Files\Java\jdk1.6.0\bin\javac.exe" -g -classpath "C:\Documents and Settings\Admin\My Documents" -d "C:\Documents and Settings\Admin\My Documents" "C:\Documents and Settings
error display
error display  I am creating a web page...I have two textboxes and an add button. If nothing has been entered in the textboxes and if I click the add button , I have to get pop up box indicating that "please fill in the fields
forbidden error
forbidden error  Hi, I have created one search engine using php and mysql database.When i tried to search user name it's showing below error. You don't have permission to access /Practices/searchdata/4/< on this server

Ads