Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jonny Devine
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
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
Pie
Posts: 64838
86
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic