Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

How do I include my FrontController with <jsp:include>?  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two questions.

1) Is it possible to include a FrontController (servlet) using



because I keep getting errors no matter what I try such as NullPointerException and IllegalStateException. What is my FrontController meant to do with this request? If I use the dispatcher.foward method I get IllegalStateException: Cannot forward after response has been committed.

2) Is it possible to retrieve information from database in a JSP without a Servlet and without putting java code in the JSP?

Background: On my web application I have a sidebar in which it includes members.jsp. Members.jsp displays a list of user avatars and hyperlinks to their profiles. I also want this list of members to display all across the web application no matter what page the user is browsing. The problem with just including members.jsp is that it doesn't invoke my FrontController servlet.
 
Author and ninkuma
Marshal
Posts: 66797
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jonny Devine wrote:1) Is it possible to include a FrontController (servlet) using ...



[Edit: after reading your post a few times -- I now understand what you are asking]

Yes, you can include a URL that invokes a front controller that dispatches to an action.

You might find this article helpful to see how a Front Controller can be used in web apps.

because I keep getting errors no matter what I try such as NullPointerException and IllegalStateException. What is my FrontController meant to do with this request? If I use the dispatcher.foward method I get IllegalStateException: Cannot forward after response has been committed.



IllegalStateException usually means that you have emitted some output before a forward. The null pointer is always the result of a programming bug. We'll need more info.

2) Is it possible to retrieve information from database in a JSP without a Servlet and without putting java code in the JSP?



Possible? Yes.

A really really bad idea? Certainly.

Again, use the right tool for the job.



 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66797
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Background: On my web application I have a sidebar in which it includes members.jsp.



Ah, that makes the question make a little more sense. So you are not "including" the Front Controller -- but using a URL that makes invokes the front controller to activate the members controller and then its JSP.

So yes, in that case you shouldn't be including the JSP directly, but rather its controller.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!