This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes redirecturl (from servlet) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "redirecturl (from servlet)" Watch "redirecturl (from servlet)" New topic
Author

redirecturl (from servlet)

raj guntupalli
Greenhorn

Joined: Dec 16, 2002
Posts: 27
Hi ,
I need to send a redirect url from my servlet to a cgi app which takes the url and redirects it to the corresponding app.Can I do something like this
and can the client take it as a url string.Thanx
I am using something like
buffer.append("SomeServlet");
buffer.append("JSESSIONID=");
buffer.append(sessionValue);
buffer.append("?");
buffer.append(req.getAttribute("remoteURLExpirationID").toString());
buffer.append("=");
buffer.append(System.currentTimeMillis());
PrintWriter out = new PrintWriter(resp.getOutputStream());
out.println(urlString);
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Is there a reason you can't use the response.sendRedirect() method ?
raj guntupalli
Greenhorn

Joined: Dec 16, 2002
Posts: 27
The end application is not a browser but is a cgi or servlet etc
I am sending response like this to the client app.Is there any way I can get the response if the following code resides in one application server and the client resides in (ex lets says tomcat and is a servlet.)Can anyone help me how to write a sample client which has to get the response and then redirect it to the browser.Thanx
resp.setContentType("text/html");
PrintWriter out = new PrintWriter(resp.getOutputStream());
out.println(plainUrl);
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12791
    
    5
You might look at the HttpClient library to be found in the Apache Commons project.
There have also be a number of discussions of this type of problem here in the last few weeks so you might browse around.
Bill
 
GeeCON Prague 2014
 
subject: redirecturl (from servlet)