top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

how to use single jsp as template

+1 vote
619 views

I have a JSP with a layout. it means the JSP has menu on the left and header on the top. now for every action the center part of the JSP should change. Is this possible?

I mean for every different action a different JSP should be included in the center of the layout JSP. If this is possible it will be of so much help. kindly help? if possible is there a solution without tiles?

posted Sep 19, 2013 by Deepak Dasgupta

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

Apache Tiles sounds like exactly what you're looking for, and works great with Struts2. You could also consider a single page app (i.e. AngularJS) approach.

answer Sep 19, 2013 by Sanketi Garg
I remember with dojo.js you needed to identify DOM attach points for Struts Action to populate the DOM at the specified attach points within the dojo.js

Does Angular.js have DOM Attach points? Are there additional considerations substituting Angular.js for JS Libraries (like Dojo or JQuery) ?
Angular makes web service requests to rest services to get its data, so there are no struts tags or attach points to deal with, but you pretty much develop the whole app as a single page that makes rest calls for data.
0 votes

Create a JSP called "template.jsp"
Use the JSTL import tag:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<c:import url="/WEB-INF/jsps/${content}.jsp"/>
</body>
</html>

Run all your requests through a servlet.

Always include a "content" request attribute when you forward requests to the template.jsp.
The content attribute should be the name of the JSP to be embedded in your template.

answer Sep 27, 2014 by anonymous
Similar Questions
0 votes

I have a number of documents that are very template like and ideal for JSP that are
1) not intended for the web and
2) need to be automatically batch processed (the output stored in output files).

How do I call the JSP processor from them command line? (it takes tomcat too long to see updated files for the purpose I have in mind)

...