• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet or JSP Issue, I'm not sure, it's my first time with both.  RSS feed

 
dav mccartney
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings all. I'm trying to do a basic Database view using servlets and JSP, and I'm not quite sure how to solve my current problem.

I've got a JSP (person_list.jsp) that will show all of the people currently in a database. Next to each person, there are hyperlinks to Update, Delete, or Create, with Update and Delete both taking the user ID from the current user and passing it on to... Somewhere? Well, it's appended to the url at this point at least, which I hoped the servlet would "see".

Since the person listing isn't part of a form, I'm not sure how to get the userID to my DeleteUser servlet. I've tried a few things here and there, but nothing is clicking and I get the following message if I try to go to:

http://localhost:8080/PillarTest/DeleteUser.do?userID=1 (or whatever the userID is)

***
HTTP Status 405 - HTTP method GET is not supported by this URL

type Status report

message HTTP method GET is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).
***

I also tried it with a doPost, but that didn't seem to work either. I suspect I'm missing something simple... Any ideas?

Below is the code for person_list.jsp:


and here's the code for the DeleteUser.java servlet:


Sorry for the long post... thanks in advance.
[ August 22, 2005: Message edited by: dav mccartney ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the query string is not going to work. Parameters passed as part of the query string are part of an HTTP GET request. Your servlet only has a method to handle POSTs. If you want your servlet to handles GETs too, implement doGet(). If you want your servlet to work as is, replace the links with a form which you POST, and include the use ID as a hidden parameter.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The servlet needs to implement doGet, not doPost. It's a trivial fix, since both have the same signature. Using a <form> tag you can specify whether you want to use GET or POST, but if you use URLs with appended parameters like you do, it's always a GET.
 
dav mccartney
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Thanks so much. Changing to the doGet worked fine. I swore I'd already tried this, but it was late when I thought I made the change so maybe I just did it all in a dream.

Thanks to you both!
dav
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!