• 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
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Servlet

 
Ranch Hand
Posts: 52
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am trying to deploy my projects site. In which i am using servlet and jsp. My directory structure is as follows

HAS--->WEB-INF--->classes

HAS is the root directory for my project where I placed all the .html and .jsp files. In WEB-INF I placed the web.xml and created a classes directory shown as above. In classes directory I placed the .class files. When I entered the URL localhost:8080/HAS/login.jsp"

it doesn't show anything. So what is wrong there. Please tell me.
 
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Swapnil,

What server are you using? How did you deploy your webapp? Did you see any errors on the server-console when starting up?

Regards,
Frits
 
Greenhorn
Posts: 16
Mac Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In addition of Frits question, Also check your context root setup property, with context root URL can be "localhost:8080/HAS/login.jsp" otherwise "localhost:8080/login.jsp"
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also check the output of
http://localhost:8080
 
Swapnil Sanghai
Ranch Hand
Posts: 52
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
First thanls for your guidence. Now the .jsp and .html pages are running browser window is showing the output now the problem of the servlet came into picture. When I click the submit button it shows that it couldn't find the resource that I given to the servlet. In deployment descriptor I have given only the servlet-name, servlet-class and the url-pattern.
The following are the lines from web.xml




Now what will be the error in my code. I am unable to find it. Please help me for that.
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One problem that I see is that your servlet class is not in a package.
 
Swapnil Sanghai
Ranch Hand
Posts: 52
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear.
Is it compulsory to put the servlet class file in package.
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. Yes. A thousand times yes. Put all classes everywhere in a package.
 
Swapnil Sanghai
Ranch Hand
Posts: 52
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Bear,
This time I have created the package structure as follows for .class file

classes-->com-->example-->web-->Authorization.class

and in the web.xml file I have given the class's address as

com.example.web.Authorization

even then it is not showing my output where I am wrong now.
Everything is same now as previous except that the new modified directory structure.
I am using Tomcat 7.0.x.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swapnil Sanghai wrote:Hi all,
I am trying to deploy my projects site. In which i am using servlet and jsp. My directory structure is as follows

HAS--->WEB-INF--->classes

HAS is the root directory for my project where I placed all the .html and .jsp files. In WEB-INF I placed the web.xml and created a classes directory shown as above. In classes directory I placed the .class files. When I entered the URL localhost:8080/HAS/login.jsp"

it doesn't show anything. So what is wrong there. Please tell me.



First of all edit your server.xml file which is in tomcat directory, in server.xml file there is one tag <serverconnector port=8080>(similar to that) change port no from 8080 to something else like 8040, and then start your server by clicking startup.bat. Now type http://localhost:8040/, if you get some web page regarding your server info, it means that server is running and there is no issue regarding server, If it didn't appear then Have you set java_home and classpath variable? and also you have to add welcome file tag in Deployment descriptor. because by default it is index.html. Even if problem persist then let me know.
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swapnil Sanghai wrote:even then it is not showing my output where I am wrong now.


At least that is now eliminated a problem source. But apparently it was not the only problem.

 
Swapnil Sanghai
Ranch Hand
Posts: 52
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Mayur: I already set the port number to 9090 as I am having oracle running on 8080. There is no problem regarding the startup of server. It is running. I just want to know that where I made mistake in web.xml as I am unable to cal servlet from my jsp page.
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Show us the updated deployment descriptor, the context path upon which you've deployed the web app, and the URL that you are trying to use to invoked the servlet.
 
Swapnil Sanghai
Ranch Hand
Posts: 52
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your suggestions.
I got my error. Everything was right in the deployment descriptor. The error was in the servlet code. I was not following the rules of overriding. So thats why it wasn't showing me the output.
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic