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

Avoiding JSTL-SQL for a Comment System  RSS feed

 
Mike Spenser
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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---
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 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
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!