• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

calling doPost from response.sendRedirect

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi All,

Can we make a call to doPost of a servlet directly via response.sendRedirect.

If yes, please tell me how.

Thanks,

Prad
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can't . sendRedirect generate new request/response and it goes to doGet method . you may call doPost from there .
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

... and it goes to doGet method . you may call doPost from there .


But you shouldn't. The HTTP spec is quite clear on the fact that GET and POST are to be used for different things. A web app that uses them interchangeably is semantically broken.
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One way to achieve that would be to send an actual response (rather than a redirect) which on page load, submits a form using a post request.

ram.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:
But you shouldn't. The HTTP spec is quite clear on the fact that GET and POST are to be used for different things. A web app that uses them interchangeably is semantically broken.


Agree.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pradhip Prakash wrote:
Hi All,

Can we make a call to doPost of a servlet directly via response.sendRedirect.

If yes, please tell me how.

Thanks,

Prad



You are on the wrong way, instead of sendredirect use HTTP Client and make Post Connection
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You are on the wrong way, instead of sendredirect use HTTP Client and make Post Connection


This won't work, since it's a browser making the request, not a Java client.
 
Jagdishkumar Patel
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:

You are on the wrong way, instead of sendredirect use HTTP Client and make Post Connection


This won't work, since it's a browser making the request, not a Java client.



you can make a connection from first servlet, from where you are doing redirect, instead of redirect make a http connection to second servlet.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

you can make a connection from first servlet, from where you are doing redirect, instead of redirect make a http connection to second servlet.


The redirect takes the request back to the browser, so that's where the request would be coming from. It's moot to speculate on what other designs are possible if this requirement is relaxed; maybe Pradhip Prakash can clarify what is actually intended.
 
Ranch Hand
Posts: 87
IntelliJ IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But you shouldn't. The HTTP spec is quite clear on the fact that GET and POST are to be used for different things. A web app that uses them interchangeably is semantically broken.



"Seetharaman Venkatasamy" Where should I get details about this? Should I read a RFC for that?
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

You can call doPost or doGet method from form submission.
At the time of form submission you can set the method.
reply
    Bookmark Topic Watch Topic
  • New Topic