Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

response.sendRedirect()  RSS feed

 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys

iam having a doubt that how to pass the url in the sendRedirect() method

if my application looks like

-Test
+web-inf
web.xml

how do i sendRedirect the welcome page
i tried response.sendRedirect("/Test/Welcome.do") ,response.sendRedirect("/Welcome.do") both things are not working

looking for your replies
amir
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
use this
----------------------------------
response.sendRedirect("Welcome.do")
//do not use slash in sendRedirect ..it is working with client
-----------------------------------
 
K Kiran Kumar
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amirtharaj,

You can give the complete URL like the following.
response.sendRedirect("http://localhost:8080/MyApp/jsp/testmethod.jsp");

In your case it might be like the following. Just try out....
response.sendRedirect("http://<serverIP>:<port>/TEST/welcome.do");

Regards,
Kiran.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this FAQ entry for an understanding of relative links and how the contextPath in server side Java applications comes into play:
http://faq.javaranch.com/java/RelativeLinks
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben

it is very useful link to understand relative path and absolute path
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!