Confusion over file access in web archives

Q

Qu0ll

I am hoping someone can explain this to me. I have a very simple WAR file
which I created in NetBeans. In the "Web Pages" section I have a file named
index.jsp in the root of that section. Let's say the project and WAR name
is "test-war", when I type in http://localhost:8080/test-war/ I get the
index.jsp page displayed. However, when I type in
http://localhost:8080/test-war/index.jsp I get a 404 error and this line
appears in the GlassFish logs:

PWC6117: File
"D:\Java\apps\glassfish-v2ur2\domains\domain1\docroot\test-war\index.jsp"
not found

How is it that it can find the index.jsp when I don't give it a name but
can't find it when I do? I am trying to work out how to do simple file
serving from a WAR running on GlassFish but can't work out how to specify
the file paths and names in the browser. Ultimately I want to be able to
type in http://localhost:8080/test-war/file1.pdf for example and have that
PDF file downloaded.

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
(e-mail address removed)
[Replace the "SixFour" with numbers to email me]
 
R

Roedy Green

How is it that it can find the index.jsp when I don't give it a name but
can't find it when I do?

IIRC you must register your various transactions you want to trigger
code. Otherwise you merely find the file statically the way you would
an ordinary html file.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Out of 135 criminals, including robbers and rapists, 118 admitted that when they were children they burned, hanged and stabbed domestic animals."
~ Ogonyok Magazine 1979.
 
S

Simon

http://localhost:8080/test-war/ I get the index.jsp page displayed.
However, when I type in http://localhost:8080/test-war/index.jsp I get a
404 error and this line appears in the GlassFish logs:

PWC6117: File
"D:\Java\apps\glassfish-v2ur2\domains\domain1\docroot\test-war\index.jsp"
not found

How is it that it can find the index.jsp when I don't give it a name but
can't find it when I do?

Don't know which tutorial you are following, but if you are doing
something similar to Sun's tutorial, your jsp pages will end up under
something like

/test-war/faces/index.jsp

if you are using faces. Look for servlet mappings in web.xml. Just a
wild guess.

Cheers,
Simon
 
M

markspace

Qu0ll said:
How is it that it can find the index.jsp when I don't give it a name but
can't find it when I do?


I'm going to guess that the .jsp files are compiled, and the .jsp source
files are never actually deployed. The byte codes are moved to a
temporary directory where the container serves them up.

Static content, like HTML and JPEGs, will stay in the locations you put
them. JSP files might be moved. Roedy pointed out that the normal way
deploy web apps is to put the paths in the config file. The web.xml
file's syntax is kinda odious, but NetBeans makes it easier to deal with.

Remember that JSPs use a MVC pattern. The container expects you to
invoke a controller (Servlet) from the web, not send control direct to a
view (JSP).

I'll try to give all this a quick test to see if I can duplicate it, and
come up with a solution.
 
A

Arne Vajhøj

Qu0ll said:
I am hoping someone can explain this to me. I have a very simple WAR
file which I created in NetBeans. In the "Web Pages" section I have a
file named index.jsp in the root of that section. Let's say the project
and WAR name is "test-war", when I type in
http://localhost:8080/test-war/ I get the index.jsp page displayed.
However, when I type in http://localhost:8080/test-war/index.jsp I get a
404 error and this line appears in the GlassFish logs:

PWC6117: File
"D:\Java\apps\glassfish-v2ur2\domains\domain1\docroot\test-war\index.jsp"
not found

Are you sure that it is index.jsp and not index.html that
gets displayed ?

Arne
 
Q

Qu0ll

Qu0ll said:
I am hoping someone can explain this to me. I have a very simple WAR file
which I created in NetBeans. In the "Web Pages" section I have a file
named index.jsp in the root of that section. Let's say the project and
WAR name is "test-war", when I type in http://localhost:8080/test-war/ I
get the index.jsp page displayed. However, when I type in
http://localhost:8080/test-war/index.jsp I get a 404 error and this line
appears in the GlassFish logs:

PWC6117: File
"D:\Java\apps\glassfish-v2ur2\domains\domain1\docroot\test-war\index.jsp"
not found

How is it that it can find the index.jsp when I don't give it a name but
can't find it when I do? I am trying to work out how to do simple file
serving from a WAR running on GlassFish but can't work out how to specify
the file paths and names in the browser. Ultimately I want to be able to
type in http://localhost:8080/test-war/file1.pdf for example and have that
PDF file downloaded.

Thanks to all those who replied. The problem appears to have been some kind
of glitch with GlassFish as I can now access the JSP directly and also
serve-up any type of file by specifying it by name. I really don't know why
it didn't work at first.

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
(e-mail address removed)
[Replace the "SixFour" with numbers to email me]
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top