Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: Include directive in Tomcat4


Message #1 by "Alfian Hadi" <alfianhadi@s...> on Wed, 10 Jul 2002 10:50:29 +0700
This is a multi-part message in MIME format.

------=_NextPart_000_001C_01C228C3.E457D390
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi, Chanoch

Thanks for the explanation. This is the kind of answer I am looking for. 
I guess I have no choice but modifying all the include directives in my 
exisiting JSP application. I have tried your suggestion with using 
another subfolder that has the same name with the ROOT or CONTEXT. So in 
this case inside ROOT test, there will be another subfolder called test. 
And with this way, using <%@ include file =3D "/test/hello.html" %> 
works.

However, when I tried to use response.sendRedirect, I have to issue it 
to include the full path <% 
response.sendRedirect("/test/test/hello.html"); %> to make it works. I 
cannot do it like this: <% response.sendRedirect("/test/hello.html"); 
%>. Well, I guess this is how it works. Since the response.sendRedirect 
works that way, I think I cannot use the solution to move all my JSPs to 
another subfolder since it will mess up all my exisiting 
response.sendRedirect codes.

Anyway, thanks for the tips.


- Alfian -


  ----- Original Message -----
  From: chanoch
  To: Pro_JavaServer_Pages
  Sent: Thursday, July 11, 2002 5:20 AM
  Subject: [pro_jsp] Re: Include directive in Tomcat4


  the problem is that by doing this:

  <%@include file=3D"test/hello.html">

   you are actually including a file called

  localhost:8080/test/test/hello.html

  and not

  localhost:8080/test/hello.html

  as you were hoping. I think that is because of a misunderstood part of 
the old 1.0 specifications.

  a possible solution would be to move any included html files into a 
subdirectory of your webapplication called test/. This obviously only 
works if you have used a kind of template technique where there are a 
number of jsp pages that run the show and the rest are bits of code that 
you have seperated out into other jsp pages - so there might be some 
adjusting to do.

  THe problem is that ROOT is a web application of its own - what i mean 
by that, is that you are making the mistake of thinking of the root web 
application (http://localhost:8080 or whatever) as being a parent 
application of the others such as test. The truth is that the ROOT app 
is just a convenience but it has just the same rights as everyone else. 
Therefore when you choose an "absolute" address such as 
/test/hello.html, that is calculated from the absolute base of the 
_current_ web application - which in this context is test, not the 
absolute base of you server, which resolves to another web application 
altogether to which you have no include rights.

  Hope that makes sense because you need to understand that in order to 
fix this without amending the code. The only way I can think of to fix 
it then, is to move all included files (and you have to hope that an 
included file is never linked to directly as well.... or else you will 
have to keep two copies) into a directory called test/ within the test/ 
application so that the include directives resolve correctly.

  if I have not made myself entirely clear (as I suspect is the case) 
then please write back and I will try again. More information might help 
me too

  chanoch



  Return to Index