Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

login application in jsp-servlet

 
Abhijeet Jha
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing a small login application in jsp and sevlets:

my servlet is Login.java and the source code is:




login.jsp source code:






i have created a package named LDA under src folder. In that LDA package my Login.java servlet resides.

I tried to run the login.jsp page but i am facing error:

HTTP Status 404 -

--------------------------------------------------------------------------------

type Status report

message

description The requested resource () is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.35

please help me out!!!
 
Aniket Khadke
Greenhorn
Posts: 29
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try using /Login in form tags action attribute...
 
Abhijeet Jha
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the help!!!
application ran succesfully....
but after i click on submit button i am facing following error:

HTTP Status 404 - /Login

--------------------------------------------------------------------------------

type Status report

message /Login

description The requested resource (/Login) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.35
 
Habeeb Shaikh
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
Kindly define servlet class and its mapping url in web.xml
like

 
Abhijeet Jha
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have defined servlet mapping in web.xml as follow


<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>LDA_Management</display-name>
<servlet>
<description>
</description>
<display-name>Login</display-name>
<servlet-name>Login</servlet-name>
<servlet-class>LDA.Login</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/Login</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
 
Baseet Ahmed
Ranch Hand
Posts: 225
Java Notepad Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhijeet,

Welcome to JavaRanch.

Please either use <servlet-class>src.LDA.Login</servlet-class> in web.xml or put your Login.class in LDA package only (not in src folder).

It also depends how you have put your java files(.class) under webapp directory of your Servlet container (tomcat etc.)

--------
Regards
Ahmed
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the ServletsFaq. The action attribute should be the context path followed by the servlet path.
 
Anurag Verma
Ranch Hand
Posts: 167
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First thing that i can see is the action attribute in your jsp (Bear has already mentioned about it), it should be Login with context path as prefix to it,

Second thing is that youy are overriding the service method which should not be done ever. (unless you are left with no other option, which is rare). in this case, even if you reach your servlet, the doPost() method won't be called, only service() will be executed & an empty response will be returned.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic