aspose file tools*
The moose likes Servlets and the fly likes Calling outside JSP code without waiting for its response. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Calling outside JSP code without waiting for its response." Watch "Calling outside JSP code without waiting for its response." New topic
Author

Calling outside JSP code without waiting for its response.

Brian E
Greenhorn

Joined: Sep 07, 2001
Posts: 12
Hello All.
I have a JSP which calls an executable (written in C++) on the server. This executable does its thing and then returns me a value.
My problem is that the program takes a minute or so to run. I don't want the user to have to wait for the return value, because they don't really care about it. The servlet will basically kick off an email to the person with information obtained from the value above. So, my question is this: how can I call outside code (JSP or Servlet) from within my existing page and not have the existing page be "forwarded" to the next page.
For example:
test.jsp needs to execute program.jsp (which executes the C++ program above). test.jsp doesn't care what the return value will be from program.jsp. program.jsp will wait for the return value (Process.waitFor()) and then send an email.
This sounds a bit confusing, so let me try and say it again: I want page x to be able to launch code y which is contained in page/servlet z without affecting the output to the browser in page x.
Thoughts? If this is too confusing, please say so and I'll try to restate it.
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
I have done this trick before.
You basically use a "hidden" frame to do all the work for you, with out having to move to a new page.
I have included code to show what I mean.
4 files:
- a frameset
- a main display page
- a placed holder page (so the DOM gets created properly on all browsers)
- a jsp, you have to plug this into your appserver





You should get the idea when you run it.
James.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling outside JSP code without waiting for its response.
 
Similar Threads
xml mapping Head First Servlets and JSP
JSP Page Translation + Tomcat
Reloading a Servlet
running an executable file on the server by client
config.getInitParameter