• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get and Post with Init Params

 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code works well when I use "POST but does not work when I use "GET"
I get "This url does not support get" something of this sort

Is it because I am not allowed to use "GET" when i am retrieving Init Parameters.



My Web.xml


DrinkSelect.java


And if needed My form.html


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really not indent your code?
 
Salil Vverma
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Nabila,
What are you getting in the browser when you use get in the form.
I guess you might be getting a blank page in browser, reason being you have not overriden the doGet() method of HttpServlet Class.

Kindly let us know if you see some behavior other than this while using get form method.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It has nothing to do with init parameters. The default action of the methods in HttpServlet is to throw a "not supported" exception. Only those methods that you override (doGet, doPost etc.) will be allowed.
 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.. that helped !

I guess I was looking at the wrong file because I was pretty sure I was getting this error after overriding the Get Method and using the method "GET".

Thanks Everybody!
And sorry about the indentation.
 
Salil Vverma
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey ulf,
The default action of the methods in HttpServlet is to throw a "not supported" exception. Only those methods that you override (doGet, doPost etc.) will be allowed.


I tested and found that you are correct. but I am curious to know why does it give not supported exception. doGet is called from the service method and HttpServlet already contains and doGet method implementation. Does this protected implementation of doGet in HttpServlet always throws this exception whenever accessed ?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am curious to know why does it give not supported exception.

The HttpServlet class can't know what a servlet that extends it should do for any particular method, so it makes sense to report an error for all methods that have not been overridden.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic