Newsletter

Java Servlet login Example In Eclipse

Servlets » on Jan 19, 2013 { 16 Comments } By Sivateja

Let us discuss one simple login application using servlet and jsp, friends please refer previous articles if you still have any doubts regarding strvlets flow :-)

Directory Structure

Files Required

  • OnServletLogin.java
  • index.html
  • web.xml

index.html

web.xml

OnServletLogin.java

Output

 

You Might Also Like

  ::. About the Author .::

Java4s_Author
- Full Stack Java/J2EE & UI Web Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

16 Responses to “Java Servlet login Example In Eclipse”
  1. Sireesha says:

    Can you please talk about the tag welcome-file-list. How will the parameters defined under that tag be used. How will the webserver understand that the submit button on the index.html corresponds to the servlet-mapping LoginServlet with url pattern /login???

  2. Subair says:

    It is very helpful

  3. brijesh says:

    what are the benifits of servletconfig

  4. naresh says:

    .html file and .xml file url should same????

  5. huynh says:

    Login correct username and password but it’s redirect login failed

  6. Ankit Srivastava says:

    Can You explain the flow of this Program, how it works.

  7. akula says:

    Thanks you very much for explaning this concept,here one more thing i didn’t understand.i,e DAO.here u didn’t used…
    will u pls explain this once.

  8. Aneeq Azam says:

    it is very helpful but I needed to check entered username and password is equal to param values entered in xml
    so If you update it with that it’ll be more helpful
    thanks alot

  9. Poornachander Kota says:

    It is easy to understand..

  10. Parameswari says:

    Could you pls explain the code flow.. Am getting HTTP 405 errorHTTP method GET is not supported by this URL. Thanks!!

  11. viswanath says:

    Could you please tell me what is the difference between servlet and webservice? and which is better?

    • mahesh says:

      servlet directly takes request from the end-user(browser) but webservice doesn't takes the request directly from the end-user & it takes the request from another servlet (or) any service.webservice is very important becoz it is interoperable(platform independent,language independent) & distributed……………

  12. avi says:

    nice and very helpful

  13. Chitharanjan says:

    Is there any jar files I need to add for executing this code.

  14. Rammi says:

    hello,it is occurring error offer login

    what is error?

    HTTP Status 500 – Error instantiating servlet class java4s.ServletLogin

    type Exception report

    message Error instantiating servlet class java4s.ServletLogin

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

    exception
    javax.servlet.ServletException: Error instantiating servlet class java4s.ServletLogin
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
    org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2521)
    org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2510)
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Unknown Source)

    root cause
    java.lang.ClassNotFoundException: java4s.ServletLogin
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
    org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2521)
    org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2510)
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Unknown Source)

    note The full stack trace of the root cause is available in the Apache Tomcat/8.0.44 logs.

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Hibernate Spring Struts
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2018 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.