• 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

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
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

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
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

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic