• 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

response body

 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have this specification:
This is the plain text response part of the POST originated by the Server in the step above. Encoding must be as Name=Value fields
separated by carriage-return-linefeeds (CRLF).
status=xx
RedirectURL=xxx
StatusDetails=xxx

IMPORTANT NOTE: Before writing the three fields above to the Response object of the POST, please ensure you clear your response
buffer to remove any header code, comments or HTML. The Sage Pay Server is expecting “Status=” to be the first characters in the
response.

I am not sure what this means:
this is my attempt but i am getting an invalid state exception



the exception


but the response works, so what am i supposed to be doing?
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It might be useful to see what line of your code the exception is being thrown by (it'll be later in that stack trace), but I'd guess it's line 9 of that snippet.

I think the problem is the sendRedirect() call. That tries to set and send the headers of the response, and will throw an exception if the response is already committed. And writing to and/or flushing the output stream will commit the response (i.e. start sending content to the client).

Why are you trying to redirect? I'd expect your servlet to want to return content or redirect the client, but not both.
 
Wendy L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes it was line 9, my redirect.
umm i am doing the redirect because that is what i always do, so i don't need that line at all...
(will read the chapter about buffers again tonight)
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(And it wouldn't make any sense to redirect to the string "url" anyway.)

If you're supposed to be sending back a plain text response, redirecting wouldn't make any sense: my guess is something is expecting to get the response and do its own redirection.
 
Wendy L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the second line is the url to redirect the user to in our system.
Thanks both of you, just removing the redirect gets rid of the exception. can i just double check what is happening flow wise here

Sorry if this is a bit rambling but i am trying to understand...

the 3rd party are calling my servlet with the usual request and response.
I am updating the response
The 3rd party are reading the response (no idea how they are doing that, same way as the client wondow i suppose)
as we can't do a redirect now (the response has been played with) what are the 3rd party doing with the url i give them, starting a new post, like the user clicking a link?

yours thankfully
Wendy
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More or less. They could be sending it to the client, it could be used directly by a client and used via JavaScript, it could be presented as a link, and so on.
 
I claim this furniture in the name of The Ottoman Empire! You can keep this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic