• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Where do you put XSL templates in a J2EE app?

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on a J2EE application. It is only EJBs and Web Services. Where do I put XML/XSL templates? I have heard some say to put the path to the them in some properties file. This seems messy to me, but what would I know... Isn't there a place that I can read from that is system independent?

To date, I have been putting them in a jar file and including them in the application. I have a utility that can read them from there so long as the jar file is in the classpath. I like it because I don't have to worry about where to put the templates. It seems to fit better with the write once run anywhere concept.

Any recommendations? Is this a sucky way to do it?
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You seem to have a working solution already. From what i read here, I don't understand what you want to acheive by changing the existing solution. Maybe I am missing something......

- m
 
Rusty Enisin
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Working, yes. But it is only a prototype and not fully implemented.

I'm no guru - like the question above has not already made that clear... I like to do things the best way possible. When the majority go one way and I go the other, I want to be sure what I am doing is ok.

I question myself on this because through all my research everybody said to use a property file. That seemed like a pain. My personal dev box is windows, but the test server is Linux; prod is solaris... You have to change the property file for each environment. Ouch!

So why is it that everybody else is doing that instead of using a jar file when the jar file appears to be more independant of the OS, easier to deploy, and easier to maintain?

Is it a bad design to put the XSL templates in a jar file? Am I missing something really big - something that will bite me later for doing it this way?

Is anybody else doing using a jar file for things like this?
 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can probably store these files individually instead of jarring them up. In this way, custom patches does not require creating a new ear and war file.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I toyed with the idea of where to place the xsl files. I didn't like to place it in jar file simply because it created additional task of jaring everytime you change the xsl or if you wanted to add the xsl. So i redsigned the api's and passed in the properties to constructor for my transformer at runtime. In other words it would absorb the path at run time, that way you can just add the xsl/xml file wherever you need and call the api with the path. I think it adds flexibility to clients that make api calls with their own xml/xsl. The api may not be clean and crisp. If none of it changes then place it on class file path and jar it together. Donot worry about anything.
 
Rusty Enisin
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is something that bothered me for some time. I too did not like putting the xsl templates in a jar file, but at the time that was the only way I could avoid things that bothered me more, namely putting the path to the xsl in a properties file. Doing it that way just seemed so counterintuitive to the whole concept of write one, run anywhere. I wanted a self contained EAR or WAR file that could be depoyed anywhere.

I was so focused on getting that result, I missed the answer. I was right in front of me. Use the class loader! :roll:



This allows you to get any file relative to the application package root as an InputStream. or in other words you can add the xsl and xml files to you normal package structure and then get them. So now I just put the xsl in a my package structure like com.mycomp.resources.xsl and away I go.

This solved all kinds of things for me. Thank you Class Loader! This is all you need for web apps.

Now with EJBs, in order to make that file accessable in the package structure like that, you need to add each xsl file as an external resource to the ejb-jar.
 
Rusty Enisin
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh. By the way. To whomever is monitoring this forum, maybe this should be moved to the EJB/J2EE forum?
 
reply
    Bookmark Topic Watch Topic
  • New Topic