• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hitting a JSP from a Servlet

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic