Java Doc for ServletForwardingController.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » servlet » mvc » 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.mvc 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.springframework.web.servlet.mvc.AbstractController
   org.springframework.web.servlet.mvc.ServletForwardingController

ServletForwardingController
public class ServletForwardingController extends AbstractController implements BeanNameAware(Code)
Spring Controller implementation that forwards to a named servlet, i.e. the "servlet-name" in web.xml rather than a URL path mapping. A target servlet doesn't even need a "servlet-mapping" in web.xml in the first place: A "servlet" declaration is sufficient.

Useful to invoke an existing servlet via Spring's dispatching infrastructure, for example to apply Spring HandlerInterceptors to its requests. This will work even in a Servlet 2.2 container that does not support Servlet filters.

In particular, the main intent of this controller is to allow for applying Spring's OpenSessionInViewInterceptor or OpenPersistenceManagerInViewInterceptor to servlets in a Servlet 2.2 container. The specified "servlet-name" will simply refer to a custom servlet definition in web.xml in such a scenario. You then need to map "/myservlet" (or whatever path you choose for your servlet) onto this controller, which will in turn forward to your servlet.

In a Servlet 2.3 container, when not using Spring's own web MVC framework, it is recommended to use classic servlet mapping in combination with a filter, for example Spring's OpenSessionInViewFilter or OpenPersistenceManagerInViewFilter.

Example: web.xml, mapping all "/myservlet" requests to a Spring dispatcher. Also defines a custom "myServlet", but without servlet mapping.

 <servlet>
 <servlet-name>myServlet</servlet-name>
 <servlet-class>mypackage.TestServlet</servlet-class>
 </servlet>
 <servlet>
 <servlet-name>myDispatcher</servlet-name>
 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
 </servlet>
 <servlet-mapping>
 <servlet-name>myDispatcher</servlet-name>
 <url-pattern>/myservlet</url-pattern>
 </servlet-mapping>
Example: myDispatcher-servlet.xml, in turn forwarding "/myservlet" to your servlet (identified by servlet name). All such requests will go through the configured HandlerInterceptor chain (e.g. an OpenSessionInViewInterceptor). From the servlet point of view, everything will work as usual.
 <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
 <property name="interceptors">
 <list>
 <ref bean="openSessionInViewInterceptor"/>
 </list>
 </property>
 <property name="mappings">
 <props>
 <prop key="/myservlet">myServletForwardingController</prop>
 </props>
 </property>
 </bean>
 <bean id="myServletForwardingController" class="org.springframework.web.servlet.mvc.ServletForwardingController">
 <property name="servletName"><value>myServlet</value></property>
 </bean>

author:
   Juergen Hoeller
since:
   1.1.1
See Also:   ServletWrappingController
See Also:   org.springframework.orm.hibernate.support.OpenSessionInViewInterceptor
See Also:   org.springframework.orm.hibernate.support.OpenSessionInViewFilter
See Also:   org.springframework.orm.jdo.support.OpenPersistenceManagerInViewInterceptor
See Also:   org.springframework.orm.jdo.support.OpenPersistenceManagerInViewFilter




Method Summary
protected  ModelAndViewhandleRequestInternal(HttpServletRequest request, HttpServletResponse response)
    
public  voidsetBeanName(String name)
    
public  voidsetServletName(String servletName)
     Set the name of the servlet to forward to, i.e.
protected  booleanuseInclude(HttpServletRequest request, HttpServletResponse response)
     Determine whether to use RequestDispatcher's include or forward method.



Method Detail
handleRequestInternal
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception(Code)



setBeanName
public void setBeanName(String name)(Code)



setServletName
public void setServletName(String servletName)(Code)
Set the name of the servlet to forward to, i.e. the "servlet-name" of the target servlet in web.xml.

Default is the bean name of this controller.




useInclude
protected boolean useInclude(HttpServletRequest request, HttpServletResponse response)(Code)
Determine whether to use RequestDispatcher's include or forward method.

Performs a check whether an include URI attribute is found in the request, indicating an include request, and whether the response has already been committed. In both cases, an include will be performed, as a forward is not possible anymore.
Parameters:
  request - current HTTP request
Parameters:
  response - current HTTP response true for include, false for forward
See Also:   javax.servlet.RequestDispatcher.forward
See Also:   javax.servlet.RequestDispatcher.include
See Also:   javax.servlet.ServletResponse.isCommitted
See Also:   org.springframework.web.util.WebUtils.isIncludeRequest




Methods inherited from org.springframework.web.servlet.mvc.AbstractController
final public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc)
abstract protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc)
final public boolean isSynchronizeOnSession()(Code)(Java Doc)
final public void setSynchronizeOnSession(boolean synchronizeOnSession)(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.