wood burning stoves 2.0*
The moose likes Servlets and the fly likes Firefox doesnt find my File : Beer Selection Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Firefox doesnt find my File : Beer Selection Problem" Watch "Firefox doesnt find my File : Beer Selection Problem" New topic
Author

Firefox doesnt find my File : Beer Selection Problem

Aravind Manoharan B
Greenhorn

Joined: Dec 30, 2011
Posts: 3
Hi ,
I'm new to this forum . Kindly let me know if i made any mistakes while posting this . I have a problem in from the "Beer Selection Page" creation problem from HFS book.
The problem is like this,

1) I start my form.html as specified .
2) there in that page, i make a selection for a type of beer color.

From here, the page next should go to "file:///C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%207.0/webapps/beer/selectbeer.do " where i have given an URL mapping for selectbeer.do as

<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>


But the firefox doesnt recognize this and gives this error :

File not found

Firefox can't find the file at /C:/Program Files/Apache Software Foundation/Tomcat 7.0/webapps/beer/selectbeer.do.
Check the file name for capitalization or other typing errors.
Check to see if the file was moved, renamed or deleted.


Please Help

Regards,
Aravind M
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

You can't open servlets using file URLs. You need to go through Tomcat using http://localhost:8080/beer/selectbeer.do, assuming you are running Tomcat on your local machine on port 8080.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Aravind Manoharan B
Greenhorn

Joined: Dec 30, 2011
Posts: 3
Ya i did that . THe problem is that the mapping is not being recognized. IS it a Tomcat problem or Deployment directory problem ..

I'm confused .. I have set everything as specified in the book but stil it doesn't work !

Regards,
Aravind M.
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 876
    
  13

Your servlet mapping looks correct. Please post your form.html code and use code tags so it's more readable.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Aravind Manoharan B
Greenhorn

Joined: Dec 30, 2011
Posts: 3
HI rob,

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1 align="center">Beer Selection Page</h1>
<form method="post"
action="selectbeer.do">
Select Beer Characteristics<p>
<B>Color:</B>
<select name="color" size="1">
<option>light
<option>amber
<option>brown
<option>dark
</select>
<br><br>
<input type=submit value="Submit">
</p>
</form>
</body>
</html>


This is my form.html file..

Regards,
Aravind M.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

And this HTML file is located in the root of your web application? Because the action "selectbeer.do" is relative to the current HTML file, and to match it with /selectbeer.do the HTML file must be located in the root as well.
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 876
    
  13

I was going to suggest changing the form action to "/selectbeer.do". I thought the action just had to match the url-mapping. I didn't realize there was a mapping relationship between the calling page and the servlet.

Or maybe I just haven't had enough coffee yet this morning...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Jk Robbins wrote:I didn't realize there was a mapping relationship between the calling page and the servlet.

But there shouldn't be. Any URL that is page-relative will be relative to the URL of the current page. That's poor and fragile. Rather, server-relative URLs that begin with the context path never change and are not affected by the URL of the current page.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: Firefox doesnt find my File : Beer Selection Problem
 
Similar Threads
first program error, something is missing
Head First Servlet JSP: BeerSelect example: requested resource not available
Problem: requested resource not available
Really need help on The requested resource (/SelectBeer.do) is not available.
Cannot bring up a html page using tomcat 6.0