Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

error saving data in my database  RSS feed

 
Haythem Ben Yahia
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I set up a JSP page that retrieves values ​​from the URL and save them in a database.
so I break my code and I created a class to connect to the database and executes the JSP request, however, it doesn't work.
Here is the code of the class knowing that I tested and it works


here is my jsp page that calls the method getMyConnection() in my class Connect.java


and this is the error



i tried this to but it doesn't work


and this this the related error



please help me
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Connect.getMyConnection is a static method. This means you don't need jsp:useBean. That would be for an instance method.

Did you import the connection class on the top of your JSP? This should look like
<%@ page import="com.database.Connect" %>
 
Haythem Ben Yahia
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Connect.getMyConnection is a static method. This means you don't need jsp:useBean. That would be for an instance method.

Did you import the connection class on the top of your JSP? This should look like
<%@ page import="com.database.Connect" %>

no it doesn't work i can't import the class Connect but i can import the whole package that contains the Connect class
what's wrong with my first code??
it works perfectly with eclipse but when i decided to execute the URL directly in my browser it generates the error above.
i copied the project from my eclipse workspace into webapps of tomcat but it doesn't work.
please help
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My advice (unsurprising) would be to refactor all that Java code out of the JSP and into a controller class (or even deeper to the model level to be honest). JSP should be used for views, not data processing or data acquisition.

Java code in classes is usually easier to write and debug than obsolete scriptlets placed in JSPs.
 
Haythem Ben Yahia
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that's i'm doing.
my jsp need to store in a database so i call a class that simply call a method to store data received from the url

and then i call just my method which saves it into my database
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!