• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Firefox doesnt find my File : Beer Selection Problem

 
Aravind Manoharan B
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Aravind Manoharan B
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your servlet mapping looks correct. Please post your form.html code and use code tags so it's more readable.
 
Aravind Manoharan B
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 1801
28
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic