Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Problem with my servlet Advice?

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following code:

=================================================================

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SessionCheckServlet extends Httpservlet{

public SessionCheckServlet() {
super();
// TODO Auto-generated constructor stub
}

public void performTask(HttpServletRequest request,
HttpServletResponse response){
}

public static String checkServlet(HttpServletRequest request,
HttpServletResponse response) {
String reqUrl = request.getRequestURL().toString();
String queryString = request.getQueryString();
if (queryString != null) {
return "SUCCESS";
}else{
return "INVALID REQUEST";
}
}
}

=================================================================

I recieve the following error:

405 Method Not Allowed
HTTP method GET is not supported by this URL

Can anyone explain what's wrong? Thank you
[ May 12, 2005: Message edited by: Eddie Lee ]
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is your doGet() method?
 
Eddie Lee
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need a doGet method?

Please explain.

Thank you for repsonding.
 
Timmy Marks
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The default behavior for doGet from the HttpServlet class is to return an error message. You have to override doGet(HttpServletRequest, HttpServletResponse) to react correctly to GET requests, and doPost(HttpServletRequest, HttpServletResponse) to respond to POST requests
 
Timmy Marks
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you should check out Core Servlets and Java Server Pages from Marty Hall. It is a good introduction to Servlets, and available online for free!
[ May 12, 2005: Message edited by: Timmy Marks ]
 
Eddie Lee
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll check it out.

Thanks for the help. =)
reply
    Bookmark Topic Watch Topic
  • New Topic