wood burning stoves 2.0*
The moose likes Servlets and the fly likes MVC tutorial Head First 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 "MVC tutorial Head First" Watch "MVC tutorial Head First" New topic
Author

MVC tutorial Head First

Arsen Lupen
Greenhorn

Joined: Nov 20, 2008
Posts: 15
Hi everybody,
i am trying to make MVC tutorial of Head Firts Ch 3.
I am at the step of checking the servlet whether it works or now.
but i what i see is page not found.SelectBeer.do is the url pattern.
Could you please help to to sove problem with web.xml mapping.
because i eveything what i need according to tutorial.
Thanks in advance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

No one here is clairvoyant. Please show us your setup and mappings.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ankitt Gupta
Ranch Hand

Joined: Feb 19, 2009
Posts: 101
It will be better for us if you provide the code
Arsen Lupen
Greenhorn

Joined: Nov 20, 2008
Posts: 15
ok
the path :
http://localhost:8080/Beer-V1/form.html works well.
When i try to submit : here you are the web.xml detail



i am getting the error like this :

HTTP Status 404 - /Beer-V1/%E2%80%9DSelectBeer%E2%80%9D
type Status report

message /Beer-V1/%E2%80%9DSelectBeer%E2%80%9D

description The requested resource (/Beer-V1/%E2%80%9DSelectBeer%E2%80%9D) is not available.


When i try to directly use the link:
http://localhost:8080/Beer-V1/SelectBeer

i got this :
HTTP Status 405 - HTTP method GET is not supported by this URL

here you are the web diractory structure:
form.html is in C:\Tomcat 5.5\webapps\Beer-V1

web.xml is in
C:\Tomcat 5.5\webapps\Beer-V1\WEB-INF

What can be the problem.


Ankitt Gupta
Ranch Hand

Joined: Feb 19, 2009
Posts: 101
<url-pattern>/SelectBeer</url-pattern>

it will be

<url-pattern>/SelectBeer.do</url-pattern>
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
The 'action' value of your <form> is wrong. It should cover the exact url-pattern of the servlet.
Arsen Lupen
Greenhorn

Joined: Nov 20, 2008
Posts: 15
thanks for quick reply
my html is

and i ahve changed the web xml to


and i am gettin the same error

type Status report

message /Beer-V1/%E2%80%9DSelectBeer.do%E2%80%9D

description The requested resource (/Beer-V1/%E2%80%9DSelectBeer.do%E2%80%9D) is not available.
Arsen Lupen
Greenhorn

Joined: Nov 20, 2008
Posts: 15
web xml also SelectBeer.do

i am sorry for old file.
Ankitt Gupta
Ranch Hand

Joined: Feb 19, 2009
Posts: 101

Change your XML from



TO

Arsen Lupen
Greenhorn

Joined: Nov 20, 2008
Posts: 15
please see my las message i
I have already changed
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You're using curly quotes instead of straight quotes. See, even the syntax highlighter borks on it, it doesn't color the values blue.

Use those quotes ".
Arsen Lupen
Greenhorn

Joined: Nov 20, 2008
Posts: 15
Coulr you please expla'n me why the error 's wr'tten
type Status report with characters
%E2%80%9D


message /Beer-V1/%E2%80%9DSelectBeer.do%E2%80%9D

description The requested resource (/Beer-V1/%E2%80%9DSelectBeer.do%E2%80%9D) is not available.

Ankitt Gupta
Ranch Hand

Joined: Feb 19, 2009
Posts: 101
please show your servlet class
Arsen Lupen
Greenhorn

Joined: Nov 20, 2008
Posts: 15
Bauke you have done great.
it was beacues of qoutos.
now it works.
urrraaaaa

But why then browser didnot give any error about this quotos
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You're welcome.

You won't get an error because the straight quotes are fully optional. Those curly quotes are just seen as actual part of the value. As those curly quotes aren't part of the basic ASCII charset, they got URL encoded before sending to the server side. More about URL encoding: http://www.w3schools.com/TAGS/ref_urlencode.asp
Arsen Lupen
Greenhorn

Joined: Nov 20, 2008
Posts: 15
Thanks a lot
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Oh, when I said optional, I do not necessarily mean that you should omit them. Always use them. Not only for readability, but also to avoid problems if you have spaces in the value. E.g. would only pick the value "foo" while would pick the full value "foo bar".
Arsen Lupen
Greenhorn

Joined: Nov 20, 2008
Posts: 15
ok
i got it
thanks again
 
 
subject: MVC tutorial Head First
 
Similar Threads
Need Spring Tag lib example
Getting problem with post method
Servlet, JSP, MySQL webb app
Error The requested resource is not available
MVC implementation?