| Author |
Displaying a loading page betwen 2 pages
|
thongvan alexis
Greenhorn
Joined: Oct 18, 2012
Posts: 5
|
|
Hi,
here is my problem,
1/a user submit some data
2/data is send to an application server wich will store the result in a database
3/user is redirected to a waiting page
4/user is redirected to a page wich display the result once the data is ready
problem is, once I send my User to the waiting page, I'm stuck, since the servlet forwarded to it, it won't do anything anymore.
the servlet wich does not work (get stuck once the loading page is displayed)
Any ideas?
Thanks
|
 |
jatan bhavsar
Ranch Hand
Joined: Jul 23, 2008
Posts: 296
|
|
Hi,
Have you Debug the application ? Are you able to reach inside the if condition..? You can print the logger or debug the application and see where you stuck? Any Exception in background.
Regards
Jatan
|
 |
thongvan alexis
Greenhorn
Joined: Oct 18, 2012
Posts: 5
|
|
when entering the servlet the first timz next = false, so I'm not suposed to go inside the if.
when executing the line : getServletContext().getRequestDispatcher("/loading.html?next=true&key="+key).forward(req, resp);
Its just displaying loading.html, with the parameter from the servlet I was comming from (?next=false&key=xxx)
Basically it's not re-entering the servlet.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56529
|
|
You have a redirect in a loop?
Once you redirect of forward, that's it. You can do nothing else.
Maybe you need to back up 10 steps or so and tell us what you are actually trying to accomplish.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
thongvan alexis
Greenhorn
Joined: Oct 18, 2012
Posts: 5
|
|
Bear Bibeault wrote:You have a redirect in a loop?
the redirect is in a conditional block, so it's not really a problem
Once you redirect of forward, that's it. You can do nothing else.
yes, and i'm looking for a workaround or an other way of getting the same result.
Maybe you need to back up 10 steps or so and tell us what you are actually trying to accomplish.
this
1/a user submit some data
2/data is send to an application server wich will store the result in a database
3/user is redirected to a waiting page
4/user is redirected to a page wich display the result once the data is ready
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56529
|
|
|
How do you intend for the waiting page to know when the processing, which I assume is executing in a worker thread, is complete?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56529
|
|
|
Or, perhaps I'm reading too much into this. From your list, it seems as if the "waiting page" may be completely superfluous. If the servlet stores the data in the database, what's the purpose of the "waiting page"? What's it "waiting" for?
|
 |
thongvan alexis
Greenhorn
Joined: Oct 18, 2012
Posts: 5
|
|
it's waiting for the data to be stored in the database.
You cannot know how much tim the calculation will take before database storage, could be 2 seconds, could be 15 seconds.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56529
|
|
If it were me, I likely wouldn't bother for such a short duration. But if you want to show a "waiting" notice while a request is processing, you're going about it the wrong way. You can't redirect or forward from the servlet until it's done, so the idea of showing a waiting page while the servlet is still processing isn't viable. You could go the thread route, but that's wildly overkill for this.
What I'd do is to submit the request as an Ajax call, display a waiting notice while it's processing, and simply remove the notice when the request completes.
|
 |
thongvan alexis
Greenhorn
Joined: Oct 18, 2012
Posts: 5
|
|
Allright, impossible to do with only jsp/servlets.
I'll have to learn javascript/ajax then, thanks
|
 |
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4133
|
|
thongvan alexis wrote:I'll have to learn javascript/ajax then, thanks
Javascript libraries like JQuery make this really easy. You can get it done within an hour of Googling, coding, and testing.
|
Junilu - [How to Ask Questions] [How to Answer Questions] [MiH]
|
 |
 |
|
|
subject: Displaying a loading page betwen 2 pages
|
|
|