Get your CodeRanch badge!*
The moose likes JSP and the fly likes Template system with JSP and Servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Template system with JSP and Servlet?" Watch "Template system with JSP and Servlet?" New topic
Author

Template system with JSP and Servlet?

Karol Matysiak
Greenhorn

Joined: Aug 30, 2012
Posts: 20
Hello.

I'm think about building website with some kind of classic template.

I could do this with jsp:import, but that would mean that i have to paste few lines (header part, with title of the page param, banner/menu part and footer part) in each page and I would have to override the "content" part, and I think this is not exactly the idea of so called "templating". I know that in JSF is something like ui:composition, and I'm looking for something like this, but using JSP and servlets. Is there any jstl tag to do this, or maybe I should use framework like spring or struts?

best regards
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

SiteMesh and Tiles are among the most common layout engines, as far as I know. The Play! framework also has its own layout engine.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Karol Matysiak
Greenhorn

Joined: Aug 30, 2012
Posts: 20
so the only way is to use framework? And most of website which are JSp/Servlets based uses frameworks to build pages based on template?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

That depends upon whether you consider 3rd party implementations such as SiteMesh or Tiles to be "frameworks".

If you want to roll your own, surely you can do that. Custom tags can be of great help here. Personally, I only "reinvent the wheel" when I feel that none of the existing wheels are acceptable. I'd suggest looking at the existing systems and evaluating them for your use before dismissing them out of hand and setting out on your own.

If you want to be very "avant garde", you can also explore client-side templating. But that's not something I'd recommend for someone not already very handy on the client-side technologies (Javascript, jQuery et al).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Template system with JSP and Servlet?
 
Similar Threads
The definition of "template text"
Template Engine exist like this?
Design patterns for templates (or something like that ...)
creating a template jsp page
Updating data from jsp pages into an xml file