• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

AJAX and Java problem

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm having the following problem:

I'm sending an asynchronous request using javascript from a file named index.jsp to a servlet.



The servlet gets the request as well as the parameters sent along with the request.

The servlet performs it's task and after that it uses a RequestDispatcher to forward the request to a jsp.



The problem is that forwarding to the JSP produces no output at all in the div element 'publicTypeElected'.

Using a PrintWriter object in the servlet to print anything works and produces valid output, but if I use forward or include to pass the request to the JSP resource it won't work.

I hope anyone can help.

Thanks in advance
[ January 31, 2006: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you should not use Request Dispatcher to forward for include. When forward is used, it means that you are navigating to some other page. You should be returning back to same page where you would parse response object and update your UI.
Try not giving
RequestDispatcher rd = req.getRequestDispatcher(strSiguienteForma);rd.forward(req,res);

I hope it works.
 
Sheriff
Posts: 67585
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by s penumudi:
I think you should not use Request Dispatcher to forward for include.



Why not? What sort of shuffling around happens on the server should be completely immaterial to the client. All that matters is the response that is sent back.

Now, a redirect could certainlly botch up matters, but using the dispatcher on the server should not be an issue.

That said, I'm not sure why it is not working for the OP. My suggestion would be to carefully compare the responses, both the body and the headers, to see what is different between cases that work, and cases that do not work.
[ February 01, 2006: Message edited by: Bear Bibeault ]
 
That's a very big dog. I think I want to go home now and hug this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic