File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with my servlet Advice?

 
Eddie Lee
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Timmy Marks
Ranch Hand
Posts: 226
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is your doGet() method?
 
Eddie Lee
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need a doGet method?

Please explain.

Thank you for repsonding.
 
Timmy Marks
Ranch Hand
Posts: 226
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll check it out.

Thanks for the help. =)
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic