File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Problem with my servlet  Advice? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem with my servlet  Advice?" Watch "Problem with my servlet  Advice?" New topic
Author

Problem with my servlet Advice?

Eddie Lee
Greenhorn

Joined: Apr 27, 2005
Posts: 20
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 ]
Timmy Marks
Ranch Hand

Joined: Dec 01, 2003
Posts: 226
Where is your doGet() method?
Eddie Lee
Greenhorn

Joined: Apr 27, 2005
Posts: 20
I need a doGet method?

Please explain.

Thank you for repsonding.
Timmy Marks
Ranch Hand

Joined: Dec 01, 2003
Posts: 226
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

Joined: Dec 01, 2003
Posts: 226
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

Joined: Apr 27, 2005
Posts: 20
I'll check it out.

Thanks for the help. =)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with my servlet Advice?
 
Similar Threads
Trouble implementing front controller
LookupDispatchAction and <html:cancel> struts
GET Method Working But POST is not
Undefined label causing compile error
HTTP status 500-