• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

JSP Data Store from form  RSS feed

 
Ranch Hand
Posts: 37
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I designed a form in html and i am storing the input values in database using jdbc but while submitting the form it gives HTTP Status 500 – Internal Server Error

Below is my jsp page code to getdata from form


here you can see complete error details HTTP Status 500-Internal Error
 
Rancher
Posts: 3931
45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code should be entirely in a servlet, not a JSP page.
JSP's are intended for displaying things, not doing your processing.

This will also help immensely with any debugging...
 
Shubham Rai
Ranch Hand
Posts: 37
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i store data from a form using jsp only?
 
Sheriff
Posts: 21649
101
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you read your error page, it's actually very clear. On line 12 through 16 there is a call to getparameter which, according to the error message, does not exist on HttpServletRequest. That's true - the name is getParameter, with a capital P. Remember that Java is case sensitive, and that also applies to JSP files.

That said, Dave is right. JSP files should only be used for rendering responses, and servlets should be used for processing. The servlet can forward to a JSP to do the necessary rendering when it's done with the processing.
 
Saloon Keeper
Posts: 20510
115
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Shubham Rai wrote:how can i store data from a form using jsp only?



You've been told twice, what I tell you the third time is true. Use the JSP to present the form that will be submitted to a servlet. Let the servlet contain the database code. This is the basis for the Model/View/Controller approach, which has been the preferred way to implement graphical user interfaces ever since everyone discovered that other approaches where messy, error-prone, and hard to maintain.

Beyond that, putting code in scriptlets is something to avoid at all costs if for no other reason than that it's a   to debug code on a JSP. IDE's will happily assist you in debugging code in classes such as servlets, but the mix of data (HTML tags) and executable code in the same file makes it virtually impossible to debug code in a JSP.
 
Dave Tolls
Rancher
Posts: 3931
45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:If you read your error page, it's actually very clear. On line 12 through 16 there is a call to getparameter which, according to the error message, does not exist on HttpServletRequest. That's true - the name is getParameter, with a capital P. Remember that Java is case sensitive, and that also applies to JSP files.



And this highlights why having scriptlets lik this in JSPs is not a great idea.
Had this code been in a servlet then this typo would have been found without having to deploy to a server as the code would not have compiled.

Is it a requirement of some course that this be done in a JSP page?
 
Shubham Rai
Ranch Hand
Posts: 37
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually i am learning web development using java and i know currently JSP only that's why i write the whole code in JSP page .Thanks everyone for helping me out!
 
This is my favorite tiny ad:
Become a Java guru with IntelliJ IDEA
https://www.jetbrains.com/idea/
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!