Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Avoiding JSTL-SQL for a Comment System

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to avoid using the JSTL SQL tags because they make the code ugly, break MVC, and aren't as easy to use as if I have java class handling all sorts of extra work pre and post processing the data.

I'm working on creating a comment system so essentially I have a form which on submit pushes the values into the database.

However I want to display all the previous comments on the page too. So its simplistic to have them display by using: form in JSP view->servlet controller->Java model (validation, database, etc)->servlet response gets all the comments->JSP view displays them.

My question is how do I get to my Java model's getComments() function before submitting the form? Is there an option besides scripting it all in the JSP page? Is there some way to directly call a seperate method inside my Servlet controller that doesn't have to be associated with the same request that submitting a new comment from the form will have?
 
Marshal
Posts: 67343
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry you lost me. Why do you need access to anything just before submitting the form?
 
Mike Spenser
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the general format should be

---previous comments----
.
.
.
.
---submit comment form---
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can query the database with JSTL-SQL tags in the JSP, then you can do it from a bean before forwarding to the JSP.
Either way, it's all happening in the same request.

The form submission would be a new and entirely new request.
 
Mike Spenser
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:
If you can query the database with JSTL-SQL tags in the JSP, then you can do it from a bean before forwarding to the JSP.
Either way, it's all happening in the same request.

The form submission would be a new and entirely new request.



I'll look into that. If anyone has any links related to this that would be helpful.
 
Bear Bibeault
Marshal
Posts: 67343
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Though this isn't specific to your issue, there's an article I wrote for the JavaRanch Journal that discusses web application structure here.

It may provide some helpful background.
 
The only thing that kept the leeches off of me was this tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!