This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

unable to redirect to google.com using RequestDispatcher  RSS feed

 
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,

I'm tying to redirect my page to www.google.com using RequestDispatcher but its not working



Output :

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.IllegalArgumentException: Path http://www.google.co.in/ does not start with a "/" character
com.tg.contact.CDetails.doPost(CDetails.java:53)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.

 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Jigar Naik:
RequestDispatcher view = getServletContext().getRequestDispatcher("http://www.google.co.in/");
view.forward(req,resp);




Sorry, but you are not trying to forward it. Try response.sendRedirect() instead.
[ January 17, 2007: Message edited by: Adeel Ansari ]
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Request dispatcher works for passing control to resources within the web application.
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so is it good to use resp.sendRedirect("http://www.google.co.in/"); in this case or do i have alternative for batter performance ???
[ January 17, 2007: Message edited by: Jigar Naik ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing about performance, I suppose.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Jigar Naik:
... to use req.sendRedirect("http://www.google.co.in/"); in this ....



Should be res.
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Jigar Naik:
so is it good to use resp.sendRedirect("http://www.google.co.in/"); in this case or do i have alternative for batter performance ???



Performance?
How could you possibly alter the performance when sending a user to a 3rd party site?
 
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is a tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!