GeeCON Prague 2014*
The moose likes Servlets and the fly likes Unable to Run Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Unable to Run Servlet" Watch "Unable to Run Servlet" New topic
Author

Unable to Run Servlet

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Hi Everyone,

I am working on JSP/Servlet code in Eclipse and JBoss AS 5.1.0. I have created a Dynamic Web Project in Eclipse and created the classes and the JSP's. The problem that i face is that when i run the project on the server then i face a problem that none of the JSP's get displyed on the Browser. Could you please tell me what the problem is. I have attached a screen shot of my Servlet because i think my folder structure in Eclipse is incorrect.

Only the <welcome-file> tag's JSP get rendered in the browser and then nothing.



My web.xml file looks like:



Also want to know that is <welcome-file-list> a mandatory tag?



[Thumbnail for FolderStructure.JPG]

Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Where are the servlets ? Did you map them with servlet-name servlet-mapping ?

Could you please tell me what the problem is


You will need to give us a more descriptive error message for us to help you. You have a welcome file called Login.jsp. Technically a JSP is a servlet. Are you able to see Login.jsp ? Welcome file lists are not mandatory.

What sort of HTTP error code is the result of your request ? 404 / 500 / 503 ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Sorry about the previous web.xml file. Here is the latest one...



The thing is: without the welcome file list is i don't see any pages. I get the error message as:



And with the welcome file list. I see the Login.jsp, in which i have to enter a user name and password, but after that i don't see anything. I get the error message as:


I think there must be some problem with the the servlet code as well. Because the servlet code involves a JDBC code which normally takes some time. But here i just see the error coming almost instantly.

My servlet code is:







Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Is this a WAR or EAR ? You can mention the context path for EARs and for WARs the application WAR name becomes its context path.

If you have Hello.war the URL should be

http://localhost:8080/WAR_NAME/SERVLET_NAME/

You URL pattern says B2BLogin, however you are requesting for servlet CheckServlet, which is the display name of the application
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
So how to change them? I checked my JBoss admin console and I found that there is a "CheckServlet.war" entry in the Embedded Web Application section but there is also a CheckServletEAR.ear in the Enterprise Application section. So, i am confused that is it a WAR or and EAR?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

Somnath Mallick wrote:The thing is: without the welcome file list is i don't see any pages.


This is normal behavior. When you don't specify a welcome file, then trying to access your application on the context path will try to give you a directory listing which I think is disabled by default. That's why you see an error message.


And with the welcome file list. I see the Login.jsp, in which i have to enter a user name and password, but after that i don't see anything. I get the error message as:




I think there's something wrong here. As can be seen from the screen-shot, there is a file named HomePage.jsp (with a upper case H) and in your servlet too, you have HomePage.jsp, but then why is this error message showing homePage.jsp (with a lower case h)??


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Even I have seen that. I but i dont know from where is it picking up that! Coz everywhere in my code there is "H" and no "h".
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
The response.sendRedirect() method expects its path parameter to be relative to the server root. try response.sendRedirect("/{your context path goes here}/HomePage.jsp");


SCJP 1.5(97%) My Blog
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Could you please tell me what the context path should be?

Is it:


or

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

Context path is /CheckServlet, but don't hard code that in your servlet, use the getServletContext().getContextPath() method...
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Thanks Ankit! I tried with:

But nothing happened!

So should it be?
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
One thing i see is that, when i do a "Debug on Server" and add a break point inside the doPost method. The break point is never reached! The code gives HTTP 404 error even before the break point is reached. Please help.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
I tried a lot of stuff but i just am not able to run the jsp servet code on the server. Could you please guide me in what i am doing incorrectly! I read some guides and tutorials but none of that helped. I created a Dynamic Web Project in Eclipse and I am giving everything that I have done! I have attached my directory structure as an attachment is that may cause a problem!

My Servlet Code:





My web.xml file:

My Login.jsp:

My HomePage.jsp:


I am trying to run it on Tomcat 5.5.28! When I start the server and run the project on the server i open the URL


I get the following error:


Sorry for the long post. Lets just say I am pretty frustrated maybe i am doing some minor mistakes which i cant just figure out! Please help. I am desperate!



[Thumbnail for DirectoryStructure.JPG]

 
GeeCON Prague 2014
 
subject: Unable to Run Servlet