• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sendRedirect

 
Brijesh shah
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following statements are true?
Choose at least one answer.
a. The sendRedirect method can only accept an absolute URL
b. The sendRedirect method can only accept a relative URL
c. The sendRedirect method can accept either an absolute or relative URL
d. a redirect cannot be performed after anything has been written to the outputstream

In above ans is c and d...But i dont understand about option D..and also please let me know what is absolute or relative URL.

Thanks,
brijesh
 
dolly shah
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
d. a redirect cannot be performed after anything has been written to the outputstream


I think redirect cannot be performed after response has been committed means flush() has been called that's what written in the book.
Can anybody please clear, redirect cannot be performed after OutputStream() or flush() or both have the same meaning?

absolute path means with slash ( /url). relative path means without slash( url). Hope you will clear.
 
Abhishek Mish
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Absolute path always starts with root.
Relative path starts with reference to your current location.
Also check the below discussion
http://www.coderanch.com/t/171038/java-Web-Component-SCWCD/certification/difference-between-absolute-relative-path.
Rgds,
Abhishek
 
Abhishek Mish
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding option d,
The Response already committed ie the server has already finished writing the response header and is writing the body of the content, and after that if redirect is done it cant rewind, if done results in IllegalStateException.
I hope this clear your doubt.
 
Brijesh shah
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by dolly shah:


I think redirect cannot be performed after response has been committed means flush() has been called that's what written in the book.
Can anybody please clear, redirect cannot be performed after OutputStream() or flush() or both have the same meaning?

absolute path means with slash ( /url). relative path means without slash( url). Hope you will clear.


Hey Dolly, regarding this see page number 136 in HFSJ relative url can have url starting with or without forward slash (/) and i tink absolute path means whole path...
 
praseedha sai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

an absolute path like:
<form action="http://localhost:8080/myProject/View/target.jsp">
relate path like: <form action="target.jsp">

I think this will clear your doubt.
 
dolly shah
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brijesh, read properly from page:136. It says relative path means not relative to the root directory of this container but relative to the original request URL. But (with slash means) absolute path means relative to the root of this container.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic