aspose file tools*
The moose likes Servlets and the fly likes How do I include my FrontController with <jsp:include>? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How do I include my FrontController with <jsp:include>?" Watch "How do I include my FrontController with <jsp:include>?" New topic
Author

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

Jonny Devine
Greenhorn

Joined: Feb 08, 2012
Posts: 6
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

Joined: Jan 10, 2002
Posts: 61206
    
  66

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.




[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I include my FrontController with <jsp:include>?