This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Multiple responses to a request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Multiple responses to a request" Watch "Multiple responses to a request" New topic
Author

Multiple responses to a request

Anil C
Greenhorn

Joined: Jan 08, 2001
Posts: 16
I would like to know how the "Search a topic" feature works in this Site. As part of a request I am progessively getting screens and then finally the final output. (Is it by breaking down the search into parts and showing a screen at the end of each...which on refresh initiates the next part of the search ?...and the last screen will bringin the whole search results ?...or is it using the Sevlet push technology ?)
I am working on an application which initiates a looooooooong process ath the backend. We have to show a screen to the User saying that the process has started successfully. On receiving the request, after the validations, using the requestDespatcher.forward(), I show a "Process Initiated" screen and then start the process from the Servlet. As I have already written to the Response object's O/P stream, I am not able to show any screen to the User at the end of the process. Though not having a progress bar is acceptable to the User, what is not advisable on this setup is that I won't be able to convey any info about the success/failure status of the process also to the User.
Is "Multipart response" a solution to this problem ? I remember having read somewhere that it won't work fine with IE browser, is that right ?

[This message has been edited by Anil KC (edited July 11, 2001).]
Anoop Krishnan
Ranch Hand

Joined: May 03, 2001
Posts: 163
Hai Anil,
I not sure about my answer it is just an idea which i feel
You does seraching one by one after a search out put a page to the user which will use an html redirect to the same jsp which provide the parameters for next search
please try this simle example save it as Counter.jsp in your webserver & access it like this
http://mysite/Count.jsp?from=0
<html>
<%@ page contentType="text/html" %>
<%
int count=Integer.parseInt(request.getParameter("from"));
int nextCount=count+11;
%>
<head>
<meta http-equiv="Refresh" content="2; URL=http://localhost:8080/bank/Count.jsp?from=<%= nextCount %>">
</head>
<body>
<%
for(int i=count;i<nextCount;i++)
{
out.println("<br><b>COUNTING "+i+"</b>");
}
%>
</body>
</html>

[This message has been edited by Anoop Krishnan (edited July 13, 2001).]


I just want to know is there any body call my bean's Getter and Setter methods with "Please" in front - My favorite quip from Bugzilla
Anoop Krishnan
Ranch Hand

Joined: May 03, 2001
Posts: 163
Hai Anil,
i have some more idea specific to your problem.You make an html redirect to your servlet for a fixed time span(say 1 sec) & each request you check the status of your processing and send a new page to the user.
Your processing can be implemented as a seperate thread and you should have some access method which will return up to date staus of your application from the thread
Anil C
Greenhorn

Joined: Jan 08, 2001
Posts: 16
Hi Anoop,
Thanks for the reply.
Your reply prompted a few more questions..
1. As of now it is the Servlet that is initiating this process of mine; which is by accessing an EJB method. Though I have written and sent back the response ( before initiating the process itself), the progress bar on the browser shows the progress of the process. When the process gets completed, the display doesn't change becoz I don't have the option of writing again to an already written response object. R U suggesting calling the EJB method from another thread ?...how advisable is it to use threads in Web/App servers ?
2. I had read about something called MUltipart response where we set the content type as "multipart/x-mixed-replace". I had tested this with a package downloaded from OReilly site also. (I didn't get the expected output/feature). What I understood was that this feature allows U to write ur response in parts...so that the User progressively sees text appearing on his screen...Please correct me if my understanding is wrong
Anoop Krishnan
Ranch Hand

Joined: May 03, 2001
Posts: 163
Hai Anil,
If you are using an EJB application ofcourse it is not good to start a seperate thread in side your web application.also the multipart request & HTTP push is not supported by all the browsers.So i think you must use an applet to show your processing information to the client.I hope it will work
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple responses to a request
 
Similar Threads
Finding the OS user of a client Socket
sending back a URL
The mode flag
Request scope vs. Session scope.
please help with jsp design