include file question!
5 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mustapha_Abella
Posted On:   Tuesday, June 19, 2001 03:32 AM

JSP Test Hi there! I have a question concerning included files. I included a text file in my jsp file, but when the text file changes those changes are not reflected on the jsp file. It seems like I have to chnage the actual jsp file in order to reflect the text file changes. For example I can add just an A or any character & then the changes made to my text file are shown. Here is an example of what I am talking about: <%@ page info="A JSP test" %> <%@ include file="banner.htm" %> <%@ include file="test.txt" %> Still trying!! the date is: <%@ page   More>>
JSP Test

Hi there!


I have a question concerning included files. I included a text file in my jsp file, but when the text file changes those changes are not reflected on the jsp file. It seems like I have to chnage the actual jsp file in order to reflect the text file changes. For example I can add just an A or any character & then the changes made to my text file are shown.


Here is an example of what I am talking about:



<%@ page info="A JSP test" %>







<%@ include file="banner.htm" %>

<%@ include file="test.txt" %>

Still trying!!



the date is:



<%@ page import="java.util.Date" %>

<%= new Date() %>






How can I get the jsp file to be updated each time my 'test.txt' file has been changed?


If anyone can help I would be very grateful and thanks in advance

   <<Less

Re: include file question!

Posted By:   Anonymous  
Posted On:   Wednesday, July 4, 2001 11:47 AM

It's worth noteing that this is not ALWAYS true. JRun 3.0 (WinNT) Will reflect changes to an included file.

Re: include file question!

Posted By:   James_Froggatt  
Posted On:   Tuesday, July 3, 2001 04:32 PM

If you are using UNIX, simply go to the folder where your .jsp file (the one that included the file that you are changing) is and type

%touch (your file).jsp

This updates the time-stamp on the original 'template' .jsp file and now when you reload the .jsp file, the jsp is re-compliled as your jsp server thinks the .jsp file has changed. It's kind of like what you're already doing but is quicker.

e.g.

If you have a BIG web site and you want all your jsp's to be updated with the new include(s), type
%touch *.jsp

Re: include file question!

Posted By:   AlessandroA_Garbagnati  
Posted On:   Tuesday, June 19, 2001 11:22 AM

Hi,

Try . I'm not sure, but being a dynamic and not a static include, it could do the trick.

Re: include file question!

Posted By:   Tim_Manley  
Posted On:   Tuesday, June 19, 2001 11:17 AM

Yes, Thomas Dietrich is correct, the include will only read the
file once, when it is compiled.

A solution would be to use you favorite java.io class to read in
the file, then just insert the text into place.

Now, doing this, you might take a serious speed hit,
in which case you will need to cache the file, and maybe have
a thread looking for changes...

I have done all of this in the past, but I don't have the
code available to post. Good luck.




--T

Re: include file question!

Posted By:   Thomas_Dietrich  
Posted On:   Tuesday, June 19, 2001 06:24 AM

Hello Mustapha Abella,


What an include like this does, is copy and paste the code in the test.txt right into the jsp at compile time. So the copy and paste part doesn't happen again till the jsp page is actually recompiled(which seems to only occur when you save a change on the jsp). Since the jsp doesn't get recompiled with changes to the test.txt, any changes that are made to the test.txt file aren't seen.


It sounds like bad news, but look at it this way, any new changes in the jsp aren't seen until the jsp is recompiled also.


Sincerely,


Thomas Dietrich

About | Sitemap | Contact