Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Solution for common view pages

  Asked By: Kaua    Date: May 17    Category: Java    Views: 813
  

I want one solution for pages which have common view. For example in
some systems we have some pages that have one table , some button ,
one title, ..

Title
Buttons
Tables
Buttons
Messages
End

I want solution to reduce or remove many JSP's that have similar
code.

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Ludo Ricci     Answered On: May 17

If you want all your jsp files using a common  view, then you should make a file with the the features and include it in every JSP files that you want to display that common feature.

For example  you have a file called: header.jsp. this file containing a banner that you want to use in all your jsp pages. You have another templete file called footer.jsp that includes everything that you want to be displayed in the bottum of all your jsp files.

In the above cases you use the ( %@include=”filename”%) directive and place it in the appreciate place of your jsp file:

<%@ include file="banner.jsp” %>

This directive can be also used for dynamic feature. For example a jsp file that create or destroy a database. You use the include directive in each file that reuses the resource referenced by the directive.

There is also a more flexible approach called " Templete Tag Library". Sun has a very good tutorial about it. Here is the link: java.sun.com/.../TagLibrariesTOC.html

 
Answer #2    Answered By: Luigi Fischer     Answered On: May 17

There's a nice article available at JavaWorld which provides a solution  to this problem with JSP Templates.

 
Answer #3    Answered By: Latasha Wilson     Answered On: May 17
 
Answer #4    Answered By: Ora Hanson     Answered On: May 17

Thanks for your good information; I studied a good article about XSL and the way that we can use for generalization of or View.

The link is http://softwaredev.earthweb.com/java/article/0,,12082_1380771,00.html

 
Answer #5    Answered By: Angel Watkins     Answered On: May 17

I’ve done a big system with XML+XSLT (using Cocoon 1.8.x something around two years ago). What I can tell you is that although it looks great at surface but it becomes hard to manage imho because of the inherent limitations of XSLT language. I do prefer DVSL (see http://jakarta.apache.org/velocity/dvsl/index.html). DVSL is used in Anakia, Jakarta’s documentation/site management system. In Anakia you define the content of the docs (chapters, paragraphs and so on) in XML but you use Velocity to transform it to the html docs instead of XSLT and I found it way better than XML+XSLT documenting systems  such as Stylebook. Anyway, the moral of the story is: XSLT has many limitations, you end up generating XSLT friendly XMLs and it becomes hard to manage, in my opinion of course.



Sitemesh is great for managing “consistent look/feel, navigation, and layout scheme”, and the beauty of it is that you can use it with any web app system you want, even CGI! So far the best web app framework I’ve found with a relatively good balance between design/flexibility/MVC/simplicity is Tapestry.

 
Didn't find what you were looking for? Find more on Solution for common view pages Or get search suggestion and latest updates.




Tagged: