• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

405 error

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This a jsp related to it.I'm not using Html. Help me guys


 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mustafa Okbar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this Sql query not right then? It works in postgres.


 
Paul Clapham
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
? thanks in advance
 
Paul Clapham
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers mate. We understand the idea how to do it. cheers again
 
    Bookmark Topic Watch Topic
  • New Topic