Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling outside JSP code without waiting for its response.

 
Brian E
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic