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

Why my Servlet does not inserting data from jsp into mysql table ?  RSS feed

 
Lukasz Popiolek
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I have trouble with inserting data to mysql table.

There is my jsp page:


And there is my Rezerwuj.java servlet:


To this servlet, i need to pass 2 values: liczbaUczestnikow and idTermin.

liczbaUczestnikow should be get from :

And idTermin should be get from:



Can you give any suggestions ?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want your <input> elements to be form parameters, then they have to have a "name" attribute. You have used an "id" attribute instead.

I would suggest that you start by making hard-coded HTML which submits the correct data to your servlet. Once you have that working, then write a JSP which generates the correct HTML.

And one more thing... JSP scriptlets have been obsolete for over a decade now. So don't start learning about JSP by learning a dead technology. Write your JSPs to use JSTL and EL instead.
 
Lukasz Popiolek
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:If you want your <input> elements to be form parameters, then they have to have a "name" attribute. You have used an "id" attribute instead.

I would suggest that you start by making hard-coded HTML which submits the correct data to your servlet. Once you have that working, then write a JSP which generates the correct HTML.

And one more thing... JSP scriptlets have been obsolete for over a decade now. So don't start learning about JSP by learning a dead technology. Write your JSPs to use JSTL and EL instead.


I've tried this, but it didnt work for me. I don't have much time to do that. So I really care about time.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With an attitude like that, it's going to be hard for you to get anything done. Or more exactly, to get anything done properly. You already got something done but you don't seem satisified with it.
 
Lukasz Popiolek
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:With an attitude like that, it's going to be hard for you to get anything done. Or more exactly, to get anything done properly. You already got something done but you don't seem satisified with it.


I'm just stucked and i need suggestions/help. If you find rudeness in my attitude, I'm sorry. Could you help me ?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I already did try to help you but you rejected what I said. Or rather, you just said "it didn't work". Have a look at our FAQ entry It Doesnt Work Is Useless which explains how to write better posts.

By the way I didn't find your attitude rude, only counter-productive.
 
Lukasz Popiolek
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:I already did try to help you but you rejected what I said. Or rather, you just said "it didn't work". Have a look at our FAQ entry It Doesnt Work Is Useless which explains how to write better posts.

By the way I didn't find your attitude rude, only counter-productive.


You're right. I'm sorry. Browser returns java.null (Unknown Source) at 67 and 71 line of my servlet. So it means, it cant convert String to int (I've also tried with Long type, but it didnt help).
 
Stefan Evans
Bartender
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, in your servlet you have the variable: liczbaUczestnikow

You have a method setLiczbaUczestnikow - but you call it with the variable you then try to set it too...

There doesn't seem to be any connection between the input from the JSP page (coming in as a parameter) and the variable in the servlet.

To get that mapping, in your servlet you will probably have to retrieve that parameter coming from the jsp:




 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!