• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet

 
Swapnil Sanghai
Ranch Hand
Posts: 41
Java Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • 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.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2402
92
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • 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
 
Durgesh Vaishnav
Greenhorn
Posts: 16
Java Mac
  • Mark post as helpful
  • send pies
  • 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"
 
Anayonkar Shivalkar
Bartender
Posts: 1557
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also check the output of
http://localhost:8080
 
Swapnil Sanghai
Ranch Hand
Posts: 41
Java Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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: 41
Java Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear.
Is it compulsory to put the servlet class file in package.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Yes. A thousand times yes. Put all classes everywhere in a package.
 
Swapnil Sanghai
Ranch Hand
Posts: 41
Java Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • 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.
 
Mayur Shinde
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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: 41
Java Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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: 41
Java Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic