• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error on my first aplication

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello for everybody... I bought the Head First! Servlets and JSP on these days. I had been installed the Tom Cat 5.5 (the version 6 or above don't executes of any ways on my Windows 7, and my friends talked with me that this version is the best), and i can see the index.jsp normally.

One problem have happened... I created all the directory files that the book says, created the web.xml and placed it on WEB-INF. I maked the same with form.html, but I placed it in the correct folder.

When I tested the archive "form.html" (in the http://localhost8080/Beer-v1/form.html), my Tomcat says that the requested resource () is not available. Can anyone help me please?

PS.: Sorry for my bad english...
 
Creator of Enthuware JWS+ V6
Posts: 3411
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 Marcelo,

Welcome to javaranch!

Mostly the error you are getting is because of a directory structure error or a type error somewhere in the URL or HTML form. Try to follow this instruction and see if your problem gets solved. If not, please post you code here and use the [Code] button when adding code to your reply.

Regards,
Frits
 
Caio Marcelo
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, but my troubles isn't with the servlet, because I can't open just a simple HTML on my TomCat. I create both the fallow structure of folders:



I have all others default folders of Tomcat... Now the other structure the book wants:



Here's the web.xml code:



And them the form.html code:



PS.: The form.html code was tested in Mozilla Firefox, IE and Opera... All those browsers the archive are executed normally.
PS².: Sorry for my bad english again.

 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3411
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

Thank you, but my troubles isn't with the servlet, because I can't open just a simple HTML on my TomCat



Maybe I am not getting you, but do you mean that you are expecting Tomcat to open an internal browser? But you also mention that you tested the html on all the browsers? Did you just open the file directly?

Is the URL wrong?
http://localhost8080/Beer-v1/form.html

should be:
http://localhost:8080/Beer-v1/form.html

Regards,
Frits
 
Caio Marcelo
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I don't try anything you mean
URL isn't wrong, really :/
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

...URL isn't wrong, really


As Frits noted what URL you really accessed? Can you show us your browser screen with the URL while you get this error?
 
Caio Marcelo
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ya, sure, I can ^^

http://i55.tinypic.com/208fcbb.png
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And the directory structure inside Tomcat/webapps? What modifications in your web.xml and any in the configurations globally (conf/server.xml etc...)?
 
Caio Marcelo
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All they're like the book says... I make all the steps again, but continue with the error... This is the web.xml (in WEB-INF):

 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are these (looks like apostrophe) characters in front of tags in your real web.xml too? Have you checked the logs ($TOMCAT_HOME/logs) for any failures? Probably you might want to look in to that? Make a fresh start of the server and check the logs.
 
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check in Tomcat Manager console whether Beer-v1 got successful added in deployed project list or not.
Problem seems to be that Beer-v1 is not successfully deployed.

~ abhay
 
Caio Marcelo
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vijitha Kumara wrote:Are these (looks like apostrophe) characters in front of tags in your real web.xml too? Have you checked the logs ($TOMCAT_HOME/logs) for any failures? Probably you might want to look in to that? Make a fresh start of the server and check the logs.



Yeah, the code in the book uses that apostrophe. My Logs don't have much things, also .txt archives that says when TomCat started the service or stopped.

Abhay Agarwal wrote:check in Tomcat Manager console whether Beer-v1 got successful added in deployed project list or not.
Problem seems to be that Beer-v1 is not successfully deployed.

~ abhay



And how I can check Tomcat Manager?
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Caio Marcelo wrote:

Vijitha Kumara wrote:Are these (looks like apostrophe) characters in front of tags in your real web.xml too? Have you checked the logs ($TOMCAT_HOME/logs) for any failures? Probably you might want to look in to that? Make a fresh start of the server and check the logs.


Yeah, the code in the book uses that apostrophe. My Logs don't have much things, also .txt archives that says when TomCat started the service or stopped.


No apostrophe can be placed there, you must have parser exceptions in logs. What ".txt archives" are you talking about?

And how I can check Tomcat Manager?


Go to the tomcat home (http://localhost:<port>;) you will find a link on the top left under the "Administration". Just click that then you'll be presented the login.
Note: To enable manager login you have to edit the <Tomcat Home>/conf/tomcat-users.xml file as described in here.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marcelo:
I think I am newer than you I just bought the book yesterday and I am still in the Chapter1 exercise. Didn't you have any trouble with it???
I did all exactly as the book says and I am having that "type Status report", "message " and "description The requested resource () is not available" errors.
here is my java code:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class Ch1Servlet extends HttpServlet {

public void doget(HttpServletRequest request,
HttpServletResponse response)
throws IOException {
PrintWriter out = response.getWriter();
java.util.Date today = new java.util.Date();
out.println("<html>" +
"<body>" +
"<h1 align=center>HF\' Chapter1 Servlet</h1>" +
"<br>" + today + "</body>" + "</html>");
}
}

It compiled good. I did both directory structures as the book says and I put the files in the right place.
here is my xml file:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-class>Ch1/WEB-INF\classes\Ch1Servlet</servlet-class>

<servlet-mapping>
<servlet-name>Chapter1 Servlet</servlet-name>
<url-pattern>Serv1</url-pattern>
</servlet-mapping>
</web-app>

my class file in C:\Tomcat\webapps\ch1\WEB-INF\classes
and xml file in C:\Tomcat\webapps\ch1\WEB-INF
I point my browser to this:http://localhost:8080/ch1/Serv1
and I got the error.

Please do you or somebody else have an Idea of what could be happening.

Thank you
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch, Jorge Iparraguirre!

You may post your question in separate thread. And please make sure you use code tags (UseCodeTags) when posting code in the forums. Unformatted code makes it harder to read.

If this is the exact code you have in there then you have missed the end servlet tag in the web.xml... Can you check the logs whether any deployment errors exist (<TomcatHome>/logs/)?
 
Jorge Iparraguirre
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much Vijitha Kumara.
Yeah, that was it and it is Ok now.
Sorry I didn’t know about the use of these code tags.
 
Hoo hoo hoo! Looks like we got a live one! Here, wave this tiny ad at it:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic