HTTP Status 404 - /Login/userdetail.java

HTTP Status 404 - /Login/userdetail.java

I using netbeans to coonect.. why always error.. help pls.. thx

index.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form name="f1" action="userdetail.java" method="get">
            Username:<input type="text" name="uname">
            Password:<input type="text" name="upass">

            <input type="submit" value="Send">
        </form>
    </body>
</html>

userdetail.java
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;


    Connection myConn=null;
        Statement myStmt=null;
        ResultSet myRs=null;

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {Class.forName("com.mysql.jdbc.Driver").newInstance();

            myConn=DriverManager.getConnection("jdbc.mysql://localhost:3306/Login/userdetail.java","root","");

            myStmt=myConn.createStatement();

            String query="select * from user";

            myRs=myStmt.executeQuery(query);

            while(myRs.next());
            {
                out.println("Username"+myRs.getString("uname"));
                out.println("Password"+myRs.getString("upass"));
                out.println("</br>");
            }

            }
        catch(Exception e)
        {
            System.out.println("Exception"+e);
        }

         finally {  
            try
            {
                myConn.close();
                myStmt.close();
                myRs.close();
            }
            catch(Exception e)
            {
                System.out.println("Exception from finally"+e);
            }
            out.close();
        }
    }
View Answers

July 23, 2012 at 5:52 PM

There were some mistakes in your code. We have modified your code.

Here it is:

1) index.jsp

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <html>
        <head>

            <title>JSP Page</title>
        </head>
        <body>
            <form name="f1" action="../userdetail" method="post">
            <pre>
                Username:<input type="text" name="uname">
                Password:<input type="text" name="upass">
                         <input type="submit" value="Send">
            </pre>
    </form>
    </body>
    </html>

2) userdetail.java

  import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;

    public class LoginServlet extends HttpServlet{
      public void doPost(HttpServletRequest request,
      HttpServletResponse response)
      throws ServletException, IOException {
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      String user=request.getParameter("uname");
      String pass=request.getParameter("upass");

        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            Connection 

myConn=DriverManager.getConnection("jdbc.mysql://localhost:3306/Login

","root","root");
            Statement myStmt=myConn.createStatement();
            String query="select * from user where 

username='"+user+"' and password='"+pass+"'";
            ResultSet myRs=myStmt.executeQuery(query);

            if(myRs.next());
            {
                out.println("Welcome "+user);
            }

            }
        catch(Exception e)
        {
            System.out.println("Exception"+e);
        }


      }
    }

In the above code, Login should be your database name and user should

be your table name.

For more information, visit the following link:

http://www.roseindia.net/jsp/loginbean.shtml


July 24, 2012 at 4:45 AM

same can't to run.. error also please help..

index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form name="f1" action="userdetail.java" method="post">
            <pre>
            Username:<input type="text" name="uname">
            Password:<input type="text" name="upass">
                     <input type="submit" value="Send">
            </pre>
        </form>
    </body>
</html>

**userdetail.java**
(server I'm using wamp server to connect. 
add library
- MySQL JDBC Driver-mysql-connector-java-5.1.13-bin.jar
- apache tomcat

In the services, in NetBeans IDE already at server
-jdbc:mysql://localhost:3306/userdetail[root on Default schema

import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;


@WebServlet(name = "userdetail", urlPatterns = {"/userdetail"})
public class userdetail extends HttpServlet {

public class LoginServlet extends HttpServlet{
      public void doPost(HttpServletRequest request,
      HttpServletResponse response)
      throws ServletException, IOException {
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      String user=request.getParameter("uname");
      String pass=request.getParameter("upass");

        try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
            Connection myConn=DriverManager.getConnection("jdbc.mysql://localhost:3306/Login","root","root");
            Statement myStmt=myConn.createStatement();
            String query="select * from user where username='"+user+"' and password='"+pass+"'";
            ResultSet myRs=myStmt.executeQuery(query);

            if(myRs.next());
            {
                out.println("Welcome "+user);
            }

            }
        catch(Exception e)
        {
            System.out.println("Exception"+e);
        }


      }
    }









Related Tutorials/Questions & Answers:
HTTP Status 404 -
HTTP Status 404 -   HTTP Status 404 - type Status report message description The requested resource () is not available. Apache Tomcat/5.5.31 how to rectify the above error
HTTP Status 404 - Struts
HTTP Status 404   Hello, i am making a program of tiles using Struts2. i face error HTTP Status 404 May 4, 2010 11:31:59 AM org.apache.catalina.core.AprLifecycleListener init INFO: The Apache Tomcat Native library which
Advertisements
HTTP Status 404 - JSP-Servlet
HTTP Status 404  Respected Sir/madam, I am R.Ragavendran.. I am using J2EE1.4 SDK Application Server.. When I was working with it yesterday,Suddenly i found my server throwing the following Error: HTTP Status 404
HTTP Status 404 - /user/AddToCart.do - Struts
HTTP Status 404 user AddToCart   Hi, I download the JSP source code to run the online shopping cart. Whenever I try to add a Item to cart, it shows me the error page with HTTP Status 404 - /user/AddToCart.do What
Struts 2 : Http Status Error 404 - Struts
Struts 2 : Http Status Error 404  Hi All, I'm facing the below...: --------------------------------------------------------------------------HTTP Status 404... --------------------------------------------------------------------------- I started the tomcat server and typed http://localhost
java http 404 status error - JSP-Servlet
java http 404 status error  I have tried to call a servlet from html page.. but it is showing http 404 status error.. and the description... the following link: http://www.roseindia.net/servlets/index.shtml Thanks
error of HTTP Status 404 while running servlet on apache tomcat server
error of HTTP Status 404 while running servlet on apache tomcat server ... here, the browser responds "HTTP Status 404 - /java_mail/hello" wht could... and have set classpath properly. on typing "http://localhost:8080" i do get
HTTP Status 404 - /web/login/showLogin.action Error in Struts 2 - Struts
HTTP Status 404 - /web/login/showLogin.action Error in Struts 2  Hi... Eclipse 3.4 Struts 2 Now my question is I am trying to implement the login... the doLogin action . when I click on the link I get the following error type Status
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet  my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet. can some one help me. thx. moses
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet  my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet. can some one help me. thx. moses
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet  my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet. can some one help me. thx. moses
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet
my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet  my server is giving me erro HTTP Status 404 - /SimpleServelet/ wen i try to run the srvelet. can some one help me. thx. moses
404 status received in xmlhttp.status - Ajax
404 status received in xmlhttp.status  Hi! I tried out the code I found here using the AJAX login page. However, instead of using PHP for the server... is that I am getting the status 404, instead of 200. thus, I am unable
error "HTTP Status 500"
error "HTTP Status 500"  How to solve this error "HTTP Status 500
http 404 resource not found error
http 404 resource not found error   Sir, I have downloaded your RichLRApplication and deployed on tomcat 6 with oracle backend. Application started in tomcat manager. But when I try to run I am getting http 404 requested resource
ModuleNotFoundError: No module named 'http-status'
ModuleNotFoundError: No module named 'http-status'  Hi, My Python... 'http-status' How to remove the ModuleNotFoundError: No module named 'http-status' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'http-status'
ModuleNotFoundError: No module named 'http-status'  Hi, My Python... 'http-status' How to remove the ModuleNotFoundError: No module named 'http-status' error? Thanks   Hi, In your python environment
HTTP Status 500 -
HTTP Status 500 -   Hi, I am new to jsp... Installed Tomcat 5.5.... wrote. i can see these errors... HTTP Status 500 - type Exception report... of your tomcat. 8)Open your browser and type the following url: http://localhost
HTTP Status 500 -
HTTP Status 500 -   I've installed my Java libraries, and I am successfully able to compile and run Jave files from the command line. However, when I.... TTP Status 500 - type Exception report message description The server
Error : http status 500?
Error : http status 500?  hello sir, am using netbeans6.7.1 version i implemented one program i.e web application ..when am excuting this one i got one error http status 500...please solve this error ..when did i mistakn
defined actions in struts config still getting a HTTP 404 - Struts
I get this error HTTP Status 404 - Invalid path /pages/tiles/AddNewCurrency...defined actions in struts config still getting a HTTP 404  Hi guys... -------------------------------------------------------------------------------- type Status report message Invalid path /pages/tiles
Still getting the http 404 error - Java Beginners
Still getting the http 404 error  Dear experts, I refer... is userid? Anyway, whatever I do, I still receive the http 404 error...saying... that the login is part of my index page where I have other things in that page. So, please
ModuleNotFoundError: No module named 'http-status-code'
ModuleNotFoundError: No module named 'http-status-code'  Hi, My... named 'http-status-code' How to remove the ModuleNotFoundError: No module named 'http-status-code' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-http-status'
ModuleNotFoundError: No module named 'django-http-status'  Hi, My... named 'django-http-status' How to remove the ModuleNotFoundError: No module named 'django-http-status' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'http-status-code'
ModuleNotFoundError: No module named 'http-status-code'  Hi, My... named 'http-status-code' How to remove the ModuleNotFoundError: No module named 'http-status-code' error? Thanks   Hi, In your
http status 404-servlet action is not available - Struts
http status 404-servlet action is not available  hi, i m getting "http status 404-servlet action is not available" in my tomcat5.5 and i m using struts2.0.14 what is the problem pls tell me
Getting HTTP 404 error in Spring web MVC with Hibernate Integration
Getting HTTP 404 error in Spring web MVC with Hibernate Integration   Hi, i am Getting HTTP 404 error in Spring web MVC with Hibernate Integration...;Please visit the following links: http://www.roseindia.net/struts/hibernate-spring
HTTP Status 405 - Request method 'GET' not supported. Its urgent
HTTP Status 405 - Request method 'GET' not supported. Its urgent  When I use window.open('/admin/provisionNodeSamlPost.do?actionType=metadataview') in onclick method, following error is displaying in new window. "HTTP Status 405
loginform giving 404 error
the submit button the give error is populated. HTTP Status 404 - /login.doADS_TO_REPLACE_1 type Status report message /login.do description The requested...loginform giving 404 error  Hi, I am developing a login form code
http status 500 error in tomcat 6 while using eclipse helios
http status 500 error in tomcat 6 while using eclipse helios  ...(ServletConfig sc){ System.out.println("init() login servlet... IOException,ServletException{ System.out.println("service() login servlet
http status 500 error in tomcat 6 while using eclipse helios
http status 500 error in tomcat 6 while using eclipse helios  ...(ServletConfig sc){ System.out.println("init() login servlet... IOException,ServletException{ System.out.println("service() login servlet
http status 500 error in tomcat 6 while using eclipse helios
http status 500 error in tomcat 6 while using eclipse helios  ...(ServletConfig sc){ System.out.println("init() login servlet... IOException,ServletException{ System.out.println("service() login servlet
http status 500 error in tomcat 6 while using eclipse helios
http status 500 error in tomcat 6 while using eclipse helios  ...(ServletConfig sc){ System.out.println("init() login servlet... IOException,ServletException{ System.out.println("service() login servlet
http status 500 error in tomcat 6 while using eclipse helios
http status 500 error in tomcat 6 while using eclipse helios  ...(ServletConfig sc){ System.out.println("init() login servlet... IOException,ServletException{ System.out.println("service() login servlet
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
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
404 error
404 error   hello anybody help me when i deployed my ear file 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
loacation of errorpage in web.xml for 404 error
loacation of errorpage in web.xml for 404 error   The webpage cannot be found HTTP 404 Most likely causes: ā?¢There might be a typing error... to and look for the information you want. More information This error (HTTP 404
Error 404 on localhost:8080 Tomcat Apache 6.0.32 with Elipse IDE and IE/Other Browsers
Error 404 on localhost:8080 Tomcat Apache 6.0.32 with Elipse IDE and IE/Other Browsers  HTTP Status 404 - type Status message description... the following: http://localhost:8080 - 404 not found http://localhost:8005 - cannot
server status
server status   How to check the apache server status in unix machine
ubuntu disco Release 404 Not Found
http://in.archive.ubuntu.com/ubuntu disco-updates Release 404 Not Found [IP... Release 404 Not Found [IP: 43.255.166.254 80] Ign:7 http://security.ubuntu.com...ubuntu disco Release 404 Not Found  Hi, I am trying to update my
Database Status
Database Status  Hello Everyone, I am working on a project,its almost done with only module remaining in it i.e; it has to show the status of database in the graph chart or pie diagram in terms of percentage
An Assertion status in java.........
An Assertion status in java.........  What is an Assertion status............   Please visit the following links: http://www.roseindia.net/javatutorials/use-assertion-in-java.shtml http://www.roseindia.net/java/java
custom 404 error page php - PHP
custom 404 error page php  What is this error means: custom 404 error page php
htpp 404 error "Servlet as is not available"
htpp 404 error "Servlet as is not available"  hi iam new to struts. when iam running my struts app after filling the login form iam getting "Servlet as is not available". iam unable to find out where the error is.iam pasting my
ModuleNotFoundError: No module named 'status'
ModuleNotFoundError: No module named 'status'  Hi, My Python... 'status' How to remove the ModuleNotFoundError: No module named 'status'... to install padas library. You can install status python with following command
htpp 404 error "Servlet as is not available"
htpp 404 error "Servlet as is not available"  hi iam new to struts. when iam running my struts app after filling the login form iam getting "Servlet as is not available". iam unable to find out where the error is.iam pasting my
Getting 404 errors - Java Beginners
Getting 404 errors  Dear experts, I have embedded a login page... use the below codes:- Login... java.sql.Statement; public class login extends HttpServlet { protected void
ios hide status bar
ios hide status bar  HI, I am developing an application in IOS. Can anyone tell me how to? hide status bar? Thanks   Hi, Following code can be used: [[UIApplication sharedApplication] setStatusBarHidden:YES

Ads