Java Doc for RedirectView.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » servlet » view » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.web.servlet.view 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.springframework.web.servlet.view.AbstractView
   org.springframework.web.servlet.view.AbstractUrlBasedView
      org.springframework.web.servlet.view.RedirectView

RedirectView
public class RedirectView extends AbstractUrlBasedView (Code)

View that redirects to an absolute, context relative, or current request relative URL, exposing all model attributes as HTTP query parameters.

A URL for this view is supposed to be a HTTP redirect URL, i.e. suitable for HttpServletResponse's sendRedirect method, which is what actually does the redirect if the HTTP 1.0 flag is on, or via sending back an HTTP 303 code - if the HTTP 1.0 compatibility flag is off.

Note that while the default value for the "contextRelative" flag is off, you will probably want to almost always set it to true. With the flag off, URLs starting with "/" are considered relative to the web server root, while with the flag on, they are considered relative to the web application root. Since most web apps will never know or care what their context path actually is, they are much better off setting this flag to true, and submitting paths which are to be considered relative to the web application root.

Note that in a Servlet 2.2 environment, i.e. a servlet container which is only compliant to the limits of this spec, this class will probably fail when feeding in URLs which are not fully absolute, or relative to the current request (no leading "/"), as these are the only two types of URL that sendRedirect supports in a Servlet 2.2 environment.
author:
   Rod Johnson
author:
   Juergen Hoeller
author:
   Colin Sampaleanu
See Also:   RedirectView.setContextRelative
See Also:   RedirectView.setHttp10Compatible
See Also:   javax.servlet.http.HttpServletResponse.sendRedirect



Field Summary
final public static  StringDEFAULT_ENCODING_SCHEME
    

Constructor Summary
public  RedirectView()
     Constructor for use as a bean.
public  RedirectView(String url)
     Create a new RedirectView with the given URL.
public  RedirectView(String url, boolean contextRelative)
     Create a new RedirectView with the given URL.
public  RedirectView(String url, boolean contextRelative, boolean http10Compatible)
     Create a new RedirectView with the given URL.

Method Summary
protected  voidappendQueryProperties(StringBuffer targetUrl, Map model, String encodingScheme)
     Append query properties to the redirect URL.
protected  MapqueryProperties(Map model)
     Determine name-value pairs for query strings, which will be stringified, URL-encoded and formatted by appendQueryProperties.
final protected  voidrenderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response)
     Convert model to request parameters and redirect to the given URL.
protected  voidsendRedirect(HttpServletRequest request, HttpServletResponse response, String targetUrl, boolean http10Compatible)
    
public  voidsetContextRelative(boolean contextRelative)
     Set whether to interpret a given URL that starts with a slash ("/") as relative to the current ServletContext, i.e.
public  voidsetEncodingScheme(String encodingScheme)
     Set the encoding scheme for this view.
public  voidsetHttp10Compatible(boolean http10Compatible)
     Set whether to stay compatible with HTTP 1.0 clients.

In the default implementation, this will enforce HTTP status code 302 in any case, i.e.

protected  StringurlEncode(String input, String encodingScheme)
     URL-encode the given input String with the given encoding scheme.

Field Detail
DEFAULT_ENCODING_SCHEME
final public static String DEFAULT_ENCODING_SCHEME(Code)
The default encoding scheme: UTF-8




Constructor Detail
RedirectView
public RedirectView()(Code)
Constructor for use as a bean.



RedirectView
public RedirectView(String url)(Code)
Create a new RedirectView with the given URL.

The given URL will be considered as relative to the web server, not as relative to the current ServletContext.
Parameters:
  url - the URL to redirect to
See Also:   RedirectView.RedirectView(String,boolean)




RedirectView
public RedirectView(String url, boolean contextRelative)(Code)
Create a new RedirectView with the given URL.
Parameters:
  url - the URL to redirect to
Parameters:
  contextRelative - whether to interpret the given URL asrelative to the current ServletContext



RedirectView
public RedirectView(String url, boolean contextRelative, boolean http10Compatible)(Code)
Create a new RedirectView with the given URL.
Parameters:
  url - the URL to redirect to
Parameters:
  contextRelative - whether to interpret the given URL asrelative to the current ServletContext
Parameters:
  http10Compatible - whether to stay compatible with HTTP 1.0 clients




Method Detail
appendQueryProperties
protected void appendQueryProperties(StringBuffer targetUrl, Map model, String encodingScheme) throws UnsupportedEncodingException(Code)
Append query properties to the redirect URL. Stringifies, URL-encodes and formats model attributes as query properties.
Parameters:
  targetUrl - the StringBuffer to append the properties to
Parameters:
  model - Map that contains model attributes
Parameters:
  encodingScheme - the encoding scheme to use
throws:
  UnsupportedEncodingException - if string encoding failed
See Also:   RedirectView.queryProperties



queryProperties
protected Map queryProperties(Map model)(Code)
Determine name-value pairs for query strings, which will be stringified, URL-encoded and formatted by appendQueryProperties.

This implementation returns all model elements as-is.
See Also:   RedirectView.appendQueryProperties




renderMergedOutputModel
final protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws IOException(Code)
Convert model to request parameters and redirect to the given URL.
See Also:   RedirectView.appendQueryProperties
See Also:   RedirectView.sendRedirect



sendRedirect
protected void sendRedirect(HttpServletRequest request, HttpServletResponse response, String targetUrl, boolean http10Compatible) throws IOException(Code)
Send a redirect back to the HTTP client
Parameters:
  request - current HTTP request (allows for reacting to request method)
Parameters:
  response - current HTTP response (for sending response headers)
Parameters:
  targetUrl - the target URL to redirect to
Parameters:
  http10Compatible - whether to stay compatible with HTTP 1.0 clients
throws:
  IOException - if thrown by response methods



setContextRelative
public void setContextRelative(boolean contextRelative)(Code)
Set whether to interpret a given URL that starts with a slash ("/") as relative to the current ServletContext, i.e. as relative to the web application root.

Default is "false": A URL that starts with a slash will be interpreted as absolute, i.e. taken as-is. If true, the context path will be prepended to the URL in such a case.
See Also:   javax.servlet.http.HttpServletRequest.getContextPath




setEncodingScheme
public void setEncodingScheme(String encodingScheme)(Code)
Set the encoding scheme for this view. Default is UTF-8.



setHttp10Compatible
public void setHttp10Compatible(boolean http10Compatible)(Code)
Set whether to stay compatible with HTTP 1.0 clients.

In the default implementation, this will enforce HTTP status code 302 in any case, i.e. delegate to HttpServletResponse.sendRedirect. Turning this off will send HTTP status code 303, which is the correct code for HTTP 1.1 clients, but not understood by HTTP 1.0 clients.

Many HTTP 1.1 clients treat 302 just like 303, not making any difference. However, some clients depend on 303 when redirecting after a POST request; turn this flag off in such a scenario.
See Also:   javax.servlet.http.HttpServletResponse.sendRedirect




urlEncode
protected String urlEncode(String input, String encodingScheme) throws UnsupportedEncodingException(Code)
URL-encode the given input String with the given encoding scheme.

Default implementation uses URLEncoder.encode(input, enc) on JDK 1.4+, falling back to URLEncoder.encode(input) (which uses the platform default encoding) on JDK 1.3.
Parameters:
  input - the unencoded input String
Parameters:
  encodingScheme - the encoding scheme the encoded output String
throws:
  UnsupportedEncodingException - if thrown by the JDK URLEncoder
See Also:   java.net.URLEncoder.encode(StringString)
See Also:   java.net.URLEncoder.encode(String)




Methods inherited from org.springframework.web.servlet.view.AbstractUrlBasedView
public void afterPropertiesSet() throws Exception(Code)(Java Doc)
public String getUrl()(Code)(Java Doc)
public void setUrl(String url)(Code)(Java Doc)
public String toString()(Code)(Java Doc)

Fields inherited from org.springframework.web.servlet.view.AbstractView
final public static String DEFAULT_CONTENT_TYPE(Code)(Java Doc)

Methods inherited from org.springframework.web.servlet.view.AbstractView
public void addStaticAttribute(String name, Object value)(Code)(Java Doc)
protected RequestContext createRequestContext(HttpServletRequest request, Map model)(Code)(Java Doc)
protected void exposeModelAsRequestAttributes(Map model, HttpServletRequest request) throws Exception(Code)(Java Doc)
public Map getAttributesMap()(Code)(Java Doc)
public String getBeanName()(Code)(Java Doc)
public String getContentType()(Code)(Java Doc)
public String getRequestContextAttribute()(Code)(Java Doc)
public Map getStaticAttributes()(Code)(Java Doc)
public void render(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc)
abstract protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc)
public void setAttributes(Properties attributes)(Code)(Java Doc)
public void setAttributesCSV(String propString) throws IllegalArgumentException(Code)(Java Doc)
public void setAttributesMap(Map attributes)(Code)(Java Doc)
public void setBeanName(String beanName)(Code)(Java Doc)
public void setContentType(String contentType)(Code)(Java Doc)
public void setRequestContextAttribute(String requestContextAttribute)(Code)(Java Doc)
public String toString()(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.