• Post Reply Bookmark Topic Watch Topic
  • New Topic

Asynchronous submit ??

 
A.Perdomo
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
I need submit my form data, without refresh ( or reload ) the jsp. Any Idea? I am trying to do an asynchronous update. Is that possible?
Thanks, A.Perdomo.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(This is more of a HTML/Javascript problam than a Servlet problem)
The problem you're going to have is that a valid HTTP transaction requires a request and a response. What you want is to send a request from the client without caring about the response.
There are two ways I can think of doing this at the moment.
The first is to have a hidden frame. (ie a frame with zero width or height) You can then get that frame to submit the data, and the response gets sent to that frame but never shows up. The rest of the data in your page remains the same.
The other (stranger) way is to have an image that comes from a Servlet. You can use javascript to change the image (ie send different data to the Servlet) the Servlet can then process the data and return the same image again. This way the request is sent, the data is processed, and a response is recieved.
Not really sure I like either solution though (I hate frames )
I usually prefer to submit the page and redraw it with the data. (hang the overhead!)
Dave
 
A.Perdomo
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I found a tricky way to resolve the asynchonous update. We invoke a servlet dispatcher ( controller ), then a transaction ( model ) and finally before forward to the next jsp ( view) , we check ( in the controller ) whether the transaction need a response.
The code is:
if(strRedirectPage.equals("none"))
response.setStatus(204);
else {
response.setStatus(300);
System.out.println("\n forward to: /" + strRedirectPage);
servletContext.getRequestDispatcher("/" + strRedirectPage).forward(request, response);
}
Check the status related to HttpServletResponse. http://java.sun.com/products/servlet/2.1/api/javax.servlet.http.HttpServletResponse.html
Hope it help and best wishes, A.Perdomo.
----- Original Message -----
From: <johan.apelgren@skandia.se>
To: <perdomo@yifan.net>
Sent: Friday, 22 de November de 2002 5:02
Subject: RE: Regarding asynchronous submit question in JavaRanch

Okay,
here's an URL to your question:
http://www.coderanch.com/forums/
08601
Regards,
Johan Apelgren
-----Original Message-----
From: A.Perdomo [mailto erdomo@yifan.net]
Sent: Tuesday, November 19, 2002 20:49
To: johan.apelgren@skandia.se
Subject: Re: Regarding asynchronous submit question in JavaRanch

Hi! Could you send me the question? We had some problems considering
asyncronous update from servlets/jsp and ejb. But, I can't remember exactly
the question.
Thanks, A.Perdomo.

----- Original Message -----
From: <johan.apelgren@skandia.se>
To: <perdomo@yifan.net>
Sent: Tuesday, 19 de November de 2002 13:12
Subject: Regarding asynchronous submit question in JavaRanch

Hi!
Read your question about how to perform an asynchronous update. I need this
feature also. Have you implemented this? If so, could you briefly tell me
how?

Regards
Johan Apelgren
Software Architect
__________________________________________________________
Skandia Liv IT * +46-(0)8-788 49 34
Sveav´┐Żgen 44 * +46-(0)70-559 49 34
S-10350 Stockholm * johan.apelgren@skandia.se
http://www.skandia.se/liv
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!