Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Parse a ".TXT as a .JSP"  RSS feed

 
Marc Larochelle
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to include a file into a response with RequestDispatcher.include.
The file is NOT a .jsp file but the file has java code inside, so it needs to be compiled, etc ... Is it possible to do it "directly", without renaming the file with a ".jsp" extension ?

Thank you
Marc
[ September 16, 2005: Message edited by: Marc Larochelle ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried it? I know that we used to .include() an html file that had scriptlets, a TXT file may work the same, it may not.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting, never tried anything like this. But I would guess that it would work with an include directive but not an include action (dispatcher include). Let us know what you discover.

By the way, why can't you just rename the file? I'm curious.
[ September 16, 2005: Message edited by: Bear Bibeault ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
another option (depending on your server) may be to map the JSP servlet to also intercept requests for TXT files, but apart from thinking it may be possible I have no idea how it would behave specifically. It may not be worthwhile.
 
Marc Larochelle
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a test :



If I use a ".jsp" file, the include is working and the forward too.
If I use a ".txt" file, the forward works (but the jstl and the scriplets are not parsed by the server)
If I use a ".txt" file with the include, it doesn't work at all, I get a "getOutputStream() has already been called for this response". Is that normal?

I'm trying to do this because my client has an application that outputs .txt files on the server, and I needed to add java code to the files. I could rename the .txt to .jsp in the servlet before including it, but I'll have to keep track of deleted files etc. And it's alse a performance issue.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!