aspose file tools*
The moose likes Servlets and the fly likes 405 error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "405 error" Watch "405 error" New topic
Author

405 error

Mustafa Okbar
Greenhorn

Joined: Apr 04, 2011
Posts: 13
Dear reader,
I am a beginner when it comes to Java web application, I am having problems with the log in form. I have the form in a .jsp and the servlet will do the processing. We have a JDBC connection to access the database to then when requested to input the data it output the relevant information. But we are getting 405 error and was wondering what the issue is!


Thanks in advance
BlackOctober95
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18127
    
    8

Well, the HTTP 405 error code means "Method not allowed". So presumably whatever HTML code is accessing that (and you didn't show any HTML) is not using the POST method, which it must when you use the doPost() method in your servlet code.
Mustafa Okbar
Greenhorn

Joined: Apr 04, 2011
Posts: 13
This a jsp related to it.I'm not using Html. Help me guys


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Of course you are using HTML. Browsers don't understand anything else. Just because the HTML is created from a JSP doesn't make it not HTML.

If your form is using a POST, and your mapping is correct, the doPost() method should be invoked. The action of your form is very suspect.

Use an HTTP sniffing tool to find out what's really getting submitted to make sure it's what you think it is.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mustafa Okbar
Greenhorn

Joined: Apr 04, 2011
Posts: 13
How do you invoke the doPost method into the form or viceversa?When we run the jsp the output is not what I expect it prints tha password and usernmae that I enter eventhough it is not in the database.

Thanks in advance.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18127
    
    8

"You" don't invoke the doPost method. The browser processes the HTML code, and when you submit a form which is declared to use the POST method, it sends a POST request to your server. When your servlet container receives a POST request, it identifies the servlet which is supposed to process that request and calls its doPost method.

As for your code acting strangely, that's probably because your SQL isn't well-formed. SQL requires spaces between certain things so don't leave them out.
Mustafa Okbar
Greenhorn

Joined: Apr 04, 2011
Posts: 13
Is this Sql query not right then? It works in postgres.


Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18127
    
    8

Don't show me Java code which generates an SQL query. Show me the actual query, and then show me what happens when you copy and paste that
actual query into Postgres (as opposed to retyping it, which is surely what you must have done).
Mustafa Okbar
Greenhorn

Joined: Apr 04, 2011
Posts: 13
I think we might found the problem. Where the question marks are, after the "username =?" and password, our intention was to pass the form box named username to the relevant question mark. What happens in postgres was error at or near "AND"
Mustafa Okbar
Greenhorn

Joined: Apr 04, 2011
Posts: 13
? thanks in advance
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18127
    
    8

Yes, that's right. Obviously that text with the question marks wasn't what you tried in Postgres. Which is why I doubted it when you said you tried the "same" statement there. You will still have the bug with the missing space before "WHERE"... why are you constructing the statement that way, anyway?
Mustafa Okbar
Greenhorn

Joined: Apr 04, 2011
Posts: 13
Cheers mate. We understand the idea how to do it. cheers again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 405 error
 
Similar Threads
connectio null problem
detect the session attributes after the session is TimeOut?
servlet database connnetivity using MS SQL server
Database Connection Pooling java.lang.NullPointerException. Help please
not able to insert values in ms access database