This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hitting a JSP from a Servlet

 
Akram Reja
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a strange problem to solve. My servlet reads the source code for the JSP from the database, and writes it to a file, which the user can later hit. Before writing the JSP to a file, the servlet has to 'hit' the JSP, to make sure that the JSP gets compiled with no errors. sendRedirect and forward do not work in this scenario, because the control has to return to the servlet after 'hitting' the JSP. Can any one suggest me a soluation? I am basically looking for some sort of 'curl(a unix command)' that I can use in my servlet. Any suggestions?
-Akram.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can think of two possibilities:
1) dig into the Tomcat code and find out how to duplicate the effect of "hitting" the page by direct execution of the JSP page compiler.
2) address the page through a URLConnection to the localhost.
Bill
 
Akram Reja
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill,
Thanks for your suggestions. I understand your first suggestion, but can you please elaborate on your second suggestion? Appreciate your help.
-akram
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Akram,
I think what Bill means is this. Open an URL connection and get the InputStream object and read the contents. I tested with a java application. You can include this code in servlet also.
When you run "java Test1" you will get

at the DOs command prompt.

regds
maha anna


 
Akram Reja
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Maha. I didn't consider this possible at all. But, thanks to Bill and you, I have the solution.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic