This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes Help with Hello app Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Help with Hello app" Watch "Help with Hello app" New topic
Author

Help with Hello app

Volodymyr Shulyk
Greenhorn

Joined: Aug 14, 2012
Posts: 3
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

Joined: Nov 13, 2011
Posts: 49

Hi,

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

Volodymyr Shulyk
Greenhorn

Joined: Aug 14, 2012
Posts: 3
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

Joined: Nov 13, 2011
Posts: 49

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

Joined: Jan 20, 2009
Posts: 7
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

Joined: Jan 10, 2002
Posts: 56185
    
  13

Have you followed the steps in the ServletsFaq?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Volodymyr Shulyk
Greenhorn

Joined: Aug 14, 2012
Posts: 3
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

Joined: Jun 06, 2007
Posts: 2551
    
    2

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.

SCJP, SCWCD.
|Asking Good Questions|
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2551
    
    2

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with Hello app
 
Similar Threads
Resource not available
Unable to load servlet in Tomcat 5.5
HTTP Status 404 - Servlet 'x' is not available.
placing and configuring web.xml, servlets not available
The requested resource is not available