• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in inserting data to the table using servlet  RSS feed

 
Purva Sharma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my project I need to add some schedule information into a schedule table in the database..
I am accepting input from a user which direct the parameters here..
I am doing all the required stuff but yet code is not working
There must be some error in date object.
Please Help!!!
I am using mysql as backend
I have used same kind of code in jsp that is working fine but this is creating error

 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does "not working" mean? TellTheDetails.

Note that "processRequest" is not a method of the Servlet API, so it will never be called. I'm guessing you meant to override "doPost" instead - you should get in the habit of using the "Override" annotation.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are also asking for trouble, big trouble, by putting instance variables in your servlet. Each thread will try to use the same variables and they will stomp all over each other. Never use instance variables in a servlet.

But you are wise to move the code out of a JSP and into a servlet. Modern JSPs should have no Java code in them.
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Note that "processRequest" is not a method of the Servlet API, so it will never be called. I'm guessing you meant to override "doPost" instead - you should get in the habit of using the "Override" annotation.


This is a NetBeans thing and it's one of my pet peeves about an otherwise good IDE. The servlet template in NetBeans creates a processRequest method and inserts a call to that method inside of both doPost and doGet. It's very bad form in my opinion and encourages a bad habit. I've gotten into the habit of deleting it and using the correct method. The template can be changed but I haven't yet put the effort into doing so.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The servlet template in NetBeans creates a processRequest method and inserts a call to that method inside of both doPost and doGet.

So that's where it comes from - I had thought there must be a popular servlet tutorial that does it this way. Treating GET and POST interchangeably is very bad indeed, by violating the HTTP specification.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!