• 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

Firefox doesnt find my File : Beer Selection Problem

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22787
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22787
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic