• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading and writing to a JSP file using I/O

 
Priyha Jootu
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic