| 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
Saloon Keeper
Joined: Oct 27, 2005
Posts: 18370
|
|
|
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
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.
|
 |
Jk Robbins
Ranch Hand
Joined: Dec 16, 2010
Posts: 159
|
|
|
Your servlet mapping looks correct. Please post your form.html code and use code tags so it's more readable.
|
 |
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
Saloon Keeper
Joined: Oct 27, 2005
Posts: 18370
|
|
|
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.
|
 |
Jk Robbins
Ranch Hand
Joined: Dec 16, 2010
Posts: 159
|
|
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 opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
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.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: Firefox doesnt find my File : Beer Selection Problem
|
|
|