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!
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.
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.
"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.
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).
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"
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?
Cheers mate. We understand the idea how to do it. cheers again
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad: