aspose file tools*
The moose likes JSP and the fly likes Reading and writing to a JSP file using I/O Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Reading and writing to a JSP file using I/O" Watch "Reading and writing to a JSP file using I/O" New topic
Author

Reading and writing to a JSP file using I/O

Priyha Jootu
Ranch Hand

Joined: Sep 13, 2001
Posts: 47
Hi all,
I am reading a jsp file named 'displaySE.jsp' from another jsp named 'actual.jsp'. In the actual.jsp, I am using FileReader and BufferedReader to read the 'displaySE.jsp' and printing it to page using out.println(). But it does not print anything , but instead of a .jsp file, if i use a .txt file, it prints out properly. Why is it not printing anything from a .jsp file?
Actually i need to do this: Read the 'displaySE.jsp' from actual.jsp and search for some string like :
if(lang.equals("eng")) ss="eng.html"
in the 'displaySE.jsp' and write another line in it like: if(lang.equals("german")) ss="german.html" in it. Basically I am modifying the logic in the jsp file using I/O.
Is this possible to do? Have anyone done something similar to this before? Please help me how to do this.
Thanks,
Priyha.
Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
Originally posted by Priyha Jootu:
Basically I am modifying the logic in the jsp file using I/O.
Is this possible to do? Have anyone done something similar to this before? Please help me how to do this.
Thanks,
Priyha.


Hi,
first of all this is not a correct way to change the logic in ur jsp, as a matter of fact ur business logic should reside in the form of java beans/classes and jsp should be used only as a front end for display purpose only. It is not a good practice to include business logic in JSP. And changing the code of jsp at runtime depending on the request is even worse.
Try using MVC architecure
thanx


Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading and writing to a JSP file using I/O