Win a copy of The Business Blockchain this week in the Cloud forum!
    Bookmark Topic Watch Topic
  • New Topic

Web server code not working properly

 
Shakur Burton
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Report post to moderator
I'm having some trouble getting this code to work properly. /Although it compiles fully in cmd, for some reason I generate a 500 Internal Server Error Message when trying to retrieve either all items, or any item by ID. It also doesn't help that nothing happens when I try to retrieve something by "NumOfServings". Can anyone help point out what is exactly wrong with my current code???

This is the code that I am talking about that has compiled, but is not working properly...


This is the index.html file my jsp code is aiming to respond to...


If anyone can help identify what is causing my errors and non - functionality issues, it would be greatly appreciated. As I have debugged it myself and can't completely fix what's wrong here.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please include the full text of the error message and stack trace (please UseCodeTags to preserve formatting), and please edit your code to have proper indentation. Your code is just too hard to read as an unindented block of code.
 
Shakur Burton
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Report post to moderator
My java code for responding to html.index with...





My index.html file...


I'm sorry to forget these as well - the error stack for both:

1) My Retrieve All Method...
HTTP Status 500 - org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Enter in a Recipe ID from Recipe database, WHERE ID = 1' at line 1

type Exception report

message org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Enter in a Recipe ID from Recipe database, WHERE ID = 1' at line 1

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Enter in a Recipe ID from Recipe database, WHERE ID = 1' at line 1

root cause

org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Enter in a Recipe ID from Recipe database, WHERE ID = 1' at line 1

root cause

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Enter in a Recipe ID from Recipe database, WHERE ID = 1' at line 1


2) My Retrieve by ID method:
HTTP Status 500 - org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'the following values for Recipes: ID or NAME.' at line 1

type Exception report

message org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'the following values for Recipes: ID or NAME.' at line 1

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'the following values for Recipes: ID or NAME.' at line 1

root cause

org.glassfish.jersey.server.ContainerException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'the following values for Recipes: ID or NAME.' at line 1

root cause

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'the following values for Recipes: ID or NAME.' at line 1
[/code]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
It's pretty clear from the error messages that the problem is not with servlet technology but with your SQL syntax. I have moved this to the JDBC forum accordingly.
 
Shakur Burton
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Report post to moderator
Understood - I still need help cracking this error, unfortunately...
 
Paul Clapham
Sheriff
Posts: 21542
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Report post to moderator
Okay. So, somewhere in that code dump is the SQL statement which causes the exception. It would help if you could just post that instead of hoping people will trawl through what you posted.
 
Paul Clapham
Sheriff
Posts: 21542
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Report post to moderator
Never mind, I found it:



But that isn't even close to valid SQL. Did you accidentally copy and paste it from somewhere else, or did you really mean it to be an SQL statement?
 
Shakur Burton
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Report post to moderator
Paul Clapham wrote:Never mind, I found it:



But that isn't even close to valid SQL. Did you accidentally copy and paste it from somewhere else, or did you really mean it to be an SQL statement?


I admit that that was a full - on accident. I'm trying to get the code for Retrieving by ID in index.html to match my "Retrieve by ID" java code so it can work properly, for an example of my problems there.
 
Paul Clapham
Sheriff
Posts: 21542
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Report post to moderator
Sorry, but I'm totally lost. None of the strings you're trying to use in your Java code as SQL are anything like SQL. So trying to fiddle with the HTML to match that is not going to get you anywhere. If that's actually what you meant to say.

 
Shakur Burton
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Report post to moderator
I'd like to close this thread then and start a new topic, in order to better deal with my situation, which I have. 2 or 3 of them, to be exact.
 
    Bookmark Topic Watch Topic
  • New Topic