• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Unable to Run Servlet

 
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
FolderStructure.JPG
[Thumbnail for FolderStructure.JPG]
Folder Structure of my Project
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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)??
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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".
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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");
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please tell me what the context path should be?

Is it:


or

 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Context path is /CheckServlet, but don't hard code that in your servlet, use the getServletContext().getContextPath() method...
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ankit! I tried with:

But nothing happened!

So should it be?
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
DirectoryStructure.JPG
[Thumbnail for DirectoryStructure.JPG]
Directory Structure in Eclipse of the Project
 
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic