application.jsp vs application.cfm

Hello,

does anyone know whether there is anything like application.cfm that can be used within JSP?  That is, can application.jsp be accessed by the server for any application?  I know it's not doing it by default, but I want to see if it's possible to configure.

Thx
liltygaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cheekycjCommented:
no not really.

You can do a few things though.

You can pass your parameters from the web.xml to your application.

or

You can have a jsp file that is included using jsp:include in every page

or

You can have a servlet filter that sets certain variables to the request and then forwards to next jsp

or

You can have a property file that has key value pairs in it and read those in from the JSP.

CJ

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
liltygaAuthor Commented:
Thanks for the info CJ!
cheekycjCommented:
Let me know if you need help with any of the approaches.

CJ
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

liltygaAuthor Commented:
Actually, I need all the help I can get :)  

I am interested to find out more about each approach, namely passing parameters from the web.xml to the application, using the servlet filter, and the property file.  Would the last one just be another include file with values in it?

Thanks again CJ Are you British? (I ask because of the "cheeky" in front of your name)  :)

lil
cheekycjCommented:
parameters in web.xml:
http://www.sitepoint.com/article/523/3

this shows for individual servlets you can also do it for a web app

servlet filter:

filters aren't really meant for this but you can leverage them:
http://java.sun.com/products/servlet/Filters.html

they are run before your servlet/jsp runs.  So you can set variables to the request and then your JSP/Servlet can retrieve them.

Property file (the best approach)

I use Properties API to read properties files . here is the code for that (just an alternative):

using the same convention as above your properties file will contain:
propname=value

save it as yourpropertyfile.properties

   java.util.Properties properties = new java.util.Properties();
   try {
       // reading in properties file
       properties.load(new java.io.FileInputStream("yourpropertyfilename.properties"));
   } catch (IOException e) {
       // handle IO exception
   }
     // retrieve a property - all properties are retrieved as string values
     String propValue = properties.getProperty("propname");
     // check if property was found
     if (propValue != null) {
             // use it
     }

the jsp include would just be another .jsp file that you include using jsp:include tag

No I am not british :-) but I am Indian so have a lot of British influence in my life.  cheeky was nick given to be by my family :o)

CJ
cheekycjCommented:
r u british?

CJ
liltygaAuthor Commented:
Thanx CJ!  I actually knew a British guy named CJ who taught me the meaning of "cheeky", and thought it was such a big coicidence :)  But no, I'm just an American :)  Thanks so much again for your help.  You seem to have been coming to my rescue all week :)

lil
cheekycjCommented:
I am in the US too.  Philly.  Born in India, raised in India but now a good ol naturalized US Citizen :-)

CJ
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.