• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Fetching data from database when submit/click the button

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using jstl with html in this code if hard-coded in input field, when click on submit button not display the data from database in my project. But while creating one more jsp page and paste these code into jsp and when run jsp page it shows the data regarding hard coded. But it not working in my project when combining.


 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see a great deal of JSTL in that code.

You should not have Java code in your JSP like that.

Your form should submit to a servlet which will call a service that returns a List<SomeModel> that can then be forwarded to the JSP page for display, allowing you to use JSTL to format it.

That way you disconnect your display stuff from the Java code, and can test each bit and (hopefully) isolate any issues.
 
Rahul kumar verma
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its work when created in new project as well change the file name and run directly jsp page then it also work...
 
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rahul kumar verma wrote:Its work when created in new project as well change the file name and run directly jsp page then it also work...


Programming is not about how to get a solution.
It is about how to get a solution in correct way.
What Dave explained is the correct way of doing things in web application.
 
Rahul kumar verma
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for my side Tapas and Dave  because I'm using scriptlet only of JSP and according to that fetching data from database on click buttom
 
Tapas Chand
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rahul kumar verma wrote:Sorry for my side Tapas and Dave  because I'm using scriptlet only of JSP and according to that fetching data from database on click buttom


Yes I understand.
That is why we are suggesting you to rectify these practices.
Using scriplet is tempting and is OK in very small JSPs.
Once you are in actual projects and size of application increases, it will be very difficult to maintain and debug.
Separating the view and the logic will make your life easier.
And EL has been the standard in JSP since 14-15 years. Scriplets should be avoided.
 
Rahul kumar verma
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tapas

One more thing when run this page only instead of whole project then its working fine as what I want but at whole project its not display data when click on submit button
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added code tags to your post, Please be sure to use code tags in the future.

Do not use Java code in your JSP. It's been obsolete for 15 years. Do not uppercase your HTML. That's also an obsolete practice that makes the code harder to read.

See your other post with regards to learning how JSP works. I think you are having the same problem here.
 
a wee bit from the empire
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic