File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Reusing JSPs across applications Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Reusing JSPs across applications" Watch "Reusing JSPs across applications" New topic
Author

Reusing JSPs across applications

John Eric Hamacher
Ranch Hand

Joined: Apr 25, 2007
Posts: 230
Hello all:

I have been thinking about how I can reuse the same JSPs in different applications . . . if there could be some sort of abstraction or project that my applications could inherit from. Any thoughts on this are welcome.

Thanks
Eric
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

To what end?
Are you trying to save on disk space?
Disk space is pretty cheap and usually not worth the expense you'll put into managing this.

If it's just for code re-use, most people, these days manage this with build tools like ANT or MAVEN.
With tools like these, you can pull resources from where ever you like at build time.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
John Eric Hamacher wrote:Hello all:

I have been thinking about how I can reuse the same JSPs in different applications . . . if there could be some sort of abstraction or project that my applications could inherit from. Any thoughts on this are welcome.

Thanks
Eric

To be sure: are you writing raw Java code in JSP files instead of in Java classes? That would explain this odd question a bit more. If this is indeed the case, then the solution is simple: you should be writing Java code in Java classes, you should never be using scriptlets. This isnĀ“t 1998 anymore.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61611
    
  67

I usually avoid and dislike "me too" posts, but this one is important enough for me to add my voice to the already wise advice given here:
  • Write scriptless JSPs
  • Perform any resource sharing at the build and source control level, not at run-time


  • [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    John Eric Hamacher
    Ranch Hand

    Joined: Apr 25, 2007
    Posts: 230
    Thanks for the responses.

    I have scriptless JSP fragments I want to maintain centrally and use in multiple applications. I didn't literally mean the JSP would be inheriting other JSPs, more like the application projects would be inheriting other projects which have the JSPs to be reused.
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 61611
        
      67

    See Ben's post and my second point.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Reusing JSPs across applications