jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes redirect outsieda web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "redirect outsieda web application" Watch "redirect outsieda web application" New topic
Author

redirect outsieda web application

piotr jest
Greenhorn

Joined: Jun 19, 2008
Posts: 3
Hi
I have problem with redirecting user to webpage that is outsied of my application and on another server. I need to add httpHeader and send it via post to that webpage. When i try to snedRedirect method it move user to correct side but it send get after post and all header information gone.
Is there any way to solve this problem ?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Not really.
A redirect does nothing more than send a response code and location header to the browser, suggesting that it make a new request too the other URL.

Some other thoughts are to..
  • Build a form on a webpage with the other URL as its action and use Javascript to submit it.
  • Make the request from the server and stream the results to the browser


  • Without knowing more about your issue it would be hard to say which (if either) of these approaches would be best for you.


    Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
    Evelin Priyadarsini
    Greenhorn

    Joined: Jun 19, 2008
    Posts: 5
    Hi,
    When we use sendRedirect() method, it is a new request from the client so the data might be lost. But i am not sure about your scenario where you are talking about httpheaders.
    piotr jest
    Greenhorn

    Joined: Jun 19, 2008
    Posts: 3
    task is very simple i have to calculate some variables after that use response.addHeader metods add some headers and send user with that headers to another webpage that is on another server.

    about redirect:
    yes i read a lot about this problem and sendRedirect wont help me :/ i tried to use forword but there is problem with application context...
    i tried to submit a form and pass it with post after submit. But i read that js can't modify http headers :/ and there should not be any pages between forward action and destination page...
    I had no ide how complicated that task can be. Or maby imposible to do?
    Deepak Bala
    Bartender

    Joined: Feb 24, 2006
    Posts: 6661
        
        5

    Originally posted by piotr jest:
    task is very simple i have to calculate some variables after that use response.addHeader metods add some headers and send user with that headers to another webpage that is on another server.

    about redirect:
    yes i read a lot about this problem and sendRedirect wont help me :/ i tried to use forword but there is problem with application context...
    i tried to submit a form and pass it with post after submit. But i read that js can't modify http headers :/ and there should not be any pages between forward action and destination page...
    I had no ide how complicated that task can be. Or maby imposible to do?


    Both the suggestions made by Ben will work out pretty well. Why dont you given them a shot ?


    SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
    piotr jest
    Greenhorn

    Joined: Jun 19, 2008
    Posts: 3
    because of the safety of information... client realy wont to send thoes information that way :/
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: redirect outsieda web application