This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

unable to redirect to google.com using RequestDispatcher  RSS feed

 
Jigar Naik
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.
 
Adeel Ansari
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 ]
 
Rahul Bhattacharjee
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.
 
Ben Souther
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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!