Hi Everyone,
My situation is I have a .jsp file which i want to edit a value. Can
java read the file, search for the particular word and then modify that
word into another value ? Any links to read on this or example.
Thanks.
Roedy Green - 17 Nov 2005 06:22 GMT
>My situation is I have a .jsp file which i want to edit a value. Can
>java read the file, search for the particular word and then modify that
>word into another value ? Any links to read on this or example.
You are trying to modify your source code on the fly?
Read the file as one great string. You can read it in a single
unbuffered i/o. See http://mindprod.com/jgloss/fileio.html
for how.
Now you indexOf to find the word. Now write out the prefix. write the
word, write the suffix.
that saves creating a giant StringBuffer/String

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Rhino - 17 Nov 2005 14:20 GMT
> Hi Everyone,
>
> My situation is I have a .jsp file which i want to edit a value. Can
> java read the file, search for the particular word and then modify that
> word into another value ? Any links to read on this or example.
Sounds like an awful lot of work to me! Wouldn't it make more sense to use
your text editor or IDE to alter your JSP source?
Rhino
charles_n_may@yahoo.com - 17 Nov 2005 15:17 GMT
Can you alter your JSP to read the value on the fly from a properties
file, or some dynamic value from the HttpRequest? Alternatively, how
about changing the jsp during your build process using an Ant <replace>
or <replaceregexp> task?
> Hi Everyone,
>
[quoted text clipped - 3 lines]
>
> Thanks.
Malte - 18 Nov 2005 15:28 GMT
> Hi Everyone,
>
[quoted text clipped - 3 lines]
>
> Thanks.
Combination of awk/sed should get you going.