• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with Hello app

 
Volodymyr Shulyk
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! I'm having some issues with example app:

/webapps/hello/servlets/WelcomeServlet.html opened normally but now:

The requested resource (/hello/servlets/WelcomeServlet.html) is not available.

And if it even worked after clicking for invoking servlet if showing:

The requested resource (/hello/welcome1) is not available.

Folders:
webapps/hello/servlets/WelcomeServlet.html
webapps/hello/WEB-INF/classes/hello/WelcomeServlet.class
webapps/hello/WEB-INF/web.xml

My web.xml:

<web-app version="2.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xsi:schemalocation="http:/java.sun.com/dtd/web-app_2_3.dtd">
<servlet>
<servlet-name>welcome1</servlet-name>
<servlet-class>test.WelcomeServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>welcome1</servlet-name>
<url-pattern>welcome1</url-pattern>
</servlet-mapping>
</web-app>

Anybody have ideas? Thanks.
 
RatiKanta pal
Ranch Hand
Posts: 88
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Try <servlet-class>hello.WelcomeServlet</servlet-class>

 
Volodymyr Shulyk
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still can't invoke WelcomeServlet.html.
What it can be?
I wrote hello/servlets/WelcomeServlet.html and got - is not available.
downloaded SimpleGreet.war example works.
Maybe something with server settings? (But today morning html loads fine)

RatiKante pal, thanks it was mistake from tests before. I tried debugging, changing defferent parts. But it seems that mistake not in this place.
 
RatiKanta pal
Ranch Hand
Posts: 88
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that case check your tomcat installation folder .A folder must be there under your project name(say Helloworld).Then Check your lib folder in webapps, required jars should be there.

Check the picture.If not present redeploy it.



http://www.flash-db.com/Tutorials/helloOpenamf/images/tomcat_folders.gif
 
Mike P Ryan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Volodymyr. I think what you are trying to do is:
1 - Invoke a simple webpage
2 - Get that webpage to call a servlet.

1 - Try moving WelcomeServlet.html to the same directory that holds your WEB-INF folder. Start whatever webserver youre running and navigate to that page again, that should work.
2 - In your WelcomeServlet.html, i presume you are calling welcome1. You need to change your web.xml entry to be <servlet-class>hello.WelcomeServlet</servlet-class> to match the package name defined in the WelcomeServlet.java code
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you followed the steps in the ServletsFaq?
 
Volodymyr Shulyk
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RatiKanta pal, I have the same structure as on picture. One question: in the Deitel book says - create *.class file in WEB-INF/classes, but I often see *.java file in this folder. It changes something? (Can I create *.class file or I need to create *.java and compile from command line? It seems like a stupid question, but I can't find the answer in book)

Mike, I tried to do it with *.html file, but it isn't open anyway. And about web.xml - I reply to RatiKanta pal, that's my fault, but it isn't solve the problem.

Bear Bibeault, I can't find there an answer.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Volodymyr Shulyk wrote: in the Deitel book says - create *.class file in WEB-INF/classes

Yes that is the location where the servlet container looks for the .class files.
Volodymyr Shulyk wrote: but I often see *.java file in this folder. It changes something?

Maybe you have put .java files in there. Well this does not affect the servlet container as it is only concerned with .class files.
Volodymyr Shulyk wrote: (Can I create *.class file or I need to create *.java and compile from command line?

Exactly, compile your .java to .class and put them in WEB-INF/classes.

Volodymyr Shulyk wrote: It seems like a stupid question

At JR we believe no question is stupid or simple
So feel free to ask anything without hesitation.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more thing, when you say <servlet-class>test.WelcomeServlet</servlet-class> , it means your WelcomeServlet.class resides under a "test" directory under WEB-INF/classes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!