Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC tutorial Head First

 
Arsen Lupen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No one here is clairvoyant. Please show us your setup and mappings.
 
Ankitt Gupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will be better for us if you provide the code
 
Arsen Lupen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<url-pattern>/SelectBeer</url-pattern>

it will be

<url-pattern>/SelectBeer.do</url-pattern>
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The 'action' value of your <form> is wrong. It should cover the exact url-pattern of the servlet.
 
Arsen Lupen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
web xml also SelectBeer.do

i am sorry for old file.
 
Ankitt Gupta
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Change your XML from



TO

 
Arsen Lupen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please see my las message i
I have already changed
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please show your servlet class
 
Arsen Lupen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok
i got it
thanks again
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic