Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Really need help on The requested resource (/SelectBeer.do) is not available.

 
Jerry Bustamente
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've spent alot of time chasing my tail, am at wits end and need your help.

I've examined other posts on this forum on this topic but did not find a resolution.

I am on page 81 of the great Head First Servlets & JSP book.

After typing http://localhost/form.html into Mozilla and pressing enter I get the page that asks for a color I click on a color then I click on Submit query and get:


The requested resource (/SelectBeer.do) is not available.

(I changed to port 8o and have successfully completed the configuration and tests from http://www.coreservlets.com/Apache-Tomcat-Tutorial/ Also, I can display form.html just fine in Mozilla. FYI, this site has great Tomcat setup information.)

Here is the syntax of the form.html, web.xml, and BeerSelect.java

form.html in C:\jakarta-tomcat-5.5.4\webapps\Beer-v1

<html><body>
<h1 align="center">Beer Selection Page</h1>
<form method="POST"
action="SelectBeer.do">
Select beer characteristics<p>
Color:
<select name="color" size="1">
<option>lightening
<option>amber
<option>brown
<option>dark
</select>
<br><br>
<center>
<input type="SUBMIT">
</center>
</form></body></html>

web.xml in C:\jakarta-tomcat-5.5.4\webapps\Beer-v1\WEB-INF

<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/web-app_2_4.xsd"
version="2.4">

<servlet>
<servlet-name>Ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>

</web-app>

BeerSelect.java in C:\MyProjects\beerV1\src\com\example\web

package com.example.web;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class BeerSelect extends HttpServlet {

public void doPost

(HttpServletRequest request,
HttpServletResponse response)

throws IOException, ServletException {

response.setContentType("text/html");

PrintWriter out = response.getWriter();

out.println("Beer Selection Advice<br>");

String c = request.getParameter("color");

out.println("<br>Got beer color " + c);

}
}

The BeerSelect.java file was successfully compiled and copied to:

C:\jakarta-tomcat-5.5.4\webapps\Beer-v1\WEB-INF\classes\com\example\web

I restarted Tomcat as instructed and received the

The requested resource (/SelectBeer.do) is not available. message.

Your help is very appreciated.

Thank you,

Jerry Bustamente

ps Tomcat 5.5.4
 
Jerry Bustamente
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found my error. I believe but do not know for certain that it had something to do with the syntactical alignment of form.html and/or web.xml. I corrected both members to be IDENTICAL to what is in the Head First book and it worked perfectly as a previous colleague mentioned on this forum.

However, being new to Tomcat I found alot of doc on web regarding setup neither useful or current with the exception of

http://www.coreservlets.com/Apache-Tomcat-Tutorial/

You can even download a working configuration. After setting up my development and deployment as documented in the Head First I also downloaded the pre-configured Tomcat to compare to my directory structure and contents.

Working through the Tomcat configuration at the above link was very educational.

Given that, the Head First Servlets & JSP is wonderful especially in their method of learning which seems cutting edge.

Thanks,

Jerry Bustamente
 
Jerry Bustamente
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found my error. I believe but do not know for certain that it had something to do with the syntactical alignment of form.html and/or web.xml. I corrected both members to be IDENTICAL to what is in the Head First book and it worked perfectly as a previous colleague mentioned on this forum.

However, being new to Tomcat I found alot of doc on web regarding setup neither useful or current with the exception of

http://www.coreservlets.com/Apache-Tomcat-Tutorial/

You can even download a working configuration. After setting up my development and deployment as documented in the Head First I also downloaded the pre-configured Tomcat to compare to my directory structure and contents.

Working through the Tomcat configuration at the above link was very educational.

Given that, the Head First Servlets & JSP is wonderful especially in their method of learning which seems cutting edge.

Thanks,

Jerry Bustamente
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic