JSP Properties File Load In / Websphere

R

RigasMinho

Hello,
A while back you guys helped me load in a properties file using jsp
code which went like this:
properties = new Properties();
URL myURL=application.getResource("test.properties");
InputStream in = myURL.openStream();
properties.load( in );

That worked 100% well.

Now i have a question about what to do to read in a file in websphere.

Like the properites file has a line where i read information from it.
logfile=/hugelogfile.log

This file is stored in the webroot directory.

How do i make it so that the log file is still accessed when in
websphere?
do i change the path too:
logfile=\\\\hugelogfile.log
or
logfile=d:\\webroot\\hugelogfile.log

Anyone know the answer to this?

Let me know -
 
L

Lew

RigasMinho said:
Hello,
A while back you guys helped me load in a properties file using jsp [sic]
code which went like this:
properties = new Properties();
URL myURL=application.getResource("test.properties");
InputStream in = myURL.openStream();
properties.load( in );

That's not JSP code, that's Java code.
That worked 100% well.

Now i have a question about what to do to read in a file in websphere.
Like the properites file

Which properties
has a line where i read information from it.
logfile=/hugelogfile.log

This file is stored in the webroot directory.

Which directory is that?
How do i make it so that the log file is still accessed when in
websphere?
do i change the path too:
logfile=\\\\hugelogfile.log
or
logfile=d:\\webroot\\hugelogfile.log

Stay with forward slashes; don't switch to backslashes.

There are multiple approaches to locating resources in a J[2]EE app. The
easiest is to put locations in the web.xml deployment descriptor. Others
involve using relative paths rather than absolute paths, and understanding the
rules for where a Web app finds things (usually in a directory relative to the
app server installation or else relative to the classpath, depending on how
things are invoked).

Then there is always brute-force hardcoding the full path in at deployment
time, as in

logfile = d:/webroot/hugelogfile.log
(Assumes a Windows system)

- Lew
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

RigasMinho said:
Like the properites file has a line where i read information from it.
logfile=/hugelogfile.log

This file is stored in the webroot directory.

How do i make it so that the log file is still accessed when in
websphere?
do i change the path too:
logfile=\\\\hugelogfile.log
or
logfile=d:\\webroot\\hugelogfile.log

Anyone know the answer to this?

Any file specification that is valid for Java IO code
should work fine.

Arne
 
R

RigasMinho

RigasMinho said:
Hello,
A while back you guys helped me load in a properties file using jsp [sic]
code which went like this:
properties = new Properties();
URL myURL=application.getResource("test.properties");
InputStream in = myURL.openStream();
properties.load( in );

That's not JSP code, that's Java code.
That worked 100% well.
Now i have a question about what to do to read in a file in websphere.
Like the properites file

Which properties
has a line where i read information from it.
logfile=/hugelogfile.log
This file is stored in the webroot directory.

Which directory is that?
How do i make it so that the log file is still accessed when in
websphere?
do i change the path too:
logfile=\\\\hugelogfile.log
or
logfile=d:\\webroot\\hugelogfile.log

Stay with forward slashes; don't switch to backslashes.

There are multiple approaches to locating resources in a J[2]EE app. The
easiest is to put locations in the web.xml deployment descriptor. Others
involve using relative paths rather than absolute paths, and understanding the
rules for where a Web app finds things (usually in a directory relative to the
app server installation or else relative to the classpath, depending on how
things are invoked).

Then there is always brute-force hardcoding the full path in at deployment
time, as in

logfile = d:/webroot/hugelogfile.log
(Assumes a Windows system)

- Lew

okay so here's my problem - Thanks Lew by the way.

when i run the application from my machine (tomcat) and i use the line
logfile = d:/webroot/hugelogfile.log

It works and writes to the log file.

Now the question is when i deploy the application to websphere - how
do i make it write to the log file that is stored in teh war file.

Meaning - the war file will have all the source code / all the log
files. The app needs to somehow find the log file while its stored in
the war file itself.

Before I had
logfile = /hugelogfile.log
This would find the log file and display it but would never write to
it.

This is where my issue lies - i dont get why it would work in tomcat
(when i specifically tell where the location is) and not work when i
dont tell where the location is by using /hugelogfile.log
 
S

Sem

Any file specification that is valid for Java IO code
should work fine.

Arne

WebSphere web.xml file and Tomcat web.xml file have some difference.

When you see the structure it looks the same but there are some
difference in the two

The best way is to look this two file and make them useable and then
you

Can run your application with Web Sphere. Otherwise you are talking
two different things

--sem
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

RigasMinho said:
Now the question is when i deploy the application to websphere - how
do i make it write to the log file that is stored in teh war file.

Meaning - the war file will have all the source code / all the log
files. The app needs to somehow find the log file while its stored in
the war file itself.

You can not write to a log file inside the war file.

Arne
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Sem said:
WebSphere web.xml file and Tomcat web.xml file have some difference.

When you see the structure it looks the same but there are some
difference in the two

The best way is to look this two file and make them useable and then
you

Can run your application with Web Sphere. Otherwise you are talking
two different things

I would recommend only using features for web.xml that
are defined in the servlet specification and therefore
works in both Tomcat and WebSphere.

Arne
 
L

Lew

RigasMinho said:
when i run the application from my machine (tomcat) and i use the line
logfile = d:/webroot/hugelogfile.log

It works and writes to the log file.

Now the question is when i deploy the application to websphere - how
do i make it write to the log file that is stored in teh war file.

You can't. You have to have the log file on the host file system somewhere.

Or are you asking how to make WebSphere use the log file as specified inside
the WAR? one easy way is to change the properties file in the deployment
environment after it comes out of the WAR. Another is to build the WAR with
either a relative filename or an absolute filename relevant for the specific
host.

Yet another alternative is to load the properties through a classloader
(ClassLoader.getResource()) or via related methods that root their search in
the classpath. The classpath for a Web app is rooted at
<context>/WEB-INF/classes/.

Some things with relative pathnames in a Web app come from the context root
directory, some from the classes/ subdirectory, and some from a path relative
to the Web container (WebSphere) installation directory.
Meaning - the war file will have all the source code / all the log
files. The app needs to somehow find the log file while its stored in
the war file itself.

Are you saying that you want the actual log file to reside inside the WAR,
rather than somewhere else on the app host machine file system? That is not
possible.
This is where my issue lies - i dont get why it would work in tomcat
(when i specifically tell where the location is) and not work when i
dont tell where the location is by using /hugelogfile.log

But saying "/hugelogfile.log" does specify a location.

- Lew
 
R

RigasMinho

You can't. You have to have the log file on the host file system somewhere.

Or are you asking how to make WebSphere use the log file as specified inside
the WAR? one easy way is to change the properties file in the deployment
environment after it comes out of the WAR. Another is to build the WAR with
either a relative filename or an absolute filename relevant for the specific
host.

Yet another alternative is to load the properties through a classloader
(ClassLoader.getResource()) or via related methods that root their search in
the classpath. The classpath for a Web app is rooted at
<context>/WEB-INF/classes/.

Some things with relative pathnames in a Web app come from the context root
directory, some from the classes/ subdirectory, and some from a path relative
to the Web container (WebSphere) installation directory.


Are you saying that you want the actual log file to reside inside the WAR,
rather than somewhere else on the app host machine file system? That is not
possible.


But saying "/hugelogfile.log" does specify a location.

- Lew

Thanks guys -
I think what I was asking was impossible to do - although i wonder how
the developer did this before. I dont think it was in a war file but
a zip file (is that how weblogic is run?) anyways..

I just did the solution of storing the log file in another folder off
another system. And now it works.

I never knew you couldnt write to a log file inside the war file
itself.

THANKS for your help guys.

PS i hate programming - which is why i'm going to change my career to
become an head hunter for IT. Let me know if you want to use me to
represent you. e-mail me at (e-mail address removed) My background is all
in IT so i know what IT people want in a job. 4 year degree in CS / 1
year experience in Exchange + Servers / 1 year experience in
Programming. So why would you want to use me ? Cause i'm garunteeing
you last recruiter / headhunter you spoke with was some retarded kid
who just started to do IT recruiting who has no idea what IT is really
about except "i want to make huge commissions placing people"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top