[jboss-user] [JBoss Seam] - Re: Problems with contexts not being active
bmc
do-not-reply at jboss.com
Wed Dec 12 03:55:20 EST 2007
I actually localize the problem. Error is show if I try to redirect from my servlet to seam page. If I do redirect to simple (not seam) JSP page - everything is ok.
| request.getRequestDispatcher("/seam/index.xhtml").forward(request, httpServletResponse);
|
I don`t know how to attach a file in this forum, so I`ll describe my steps to create a example application.
I took a seam example Blog application (it comes as example application with JBoss Seam sources) add my test servlet (TestServlet.java)
| package actions;
|
| import javax.servlet.http.HttpServlet;
| import javax.servlet.http.HttpServletRequest;
| import javax.servlet.http.HttpServletResponse;
| import javax.servlet.ServletException;
| import java.io.IOException;
| import org.jboss.seam.Component;
|
| public class TestServlet extends HttpServlet {
| protected void doGet(HttpServletRequest request, HttpServletResponse httpServletResponse) throws ServletException, IOException {
| TestAction testAction = (TestAction) Component.getInstance("testAction");
|
| request.getRequestDispatcher("/seam/index.xhtml").forward(request, httpServletResponse);
| }
| }
|
add TestAction.java
| package actions;
|
| import org.jboss.seam.ScopeType;
| import org.jboss.seam.annotations.Factory;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Scope;
|
| @Scope(ScopeType.EVENT)
| @Name("testAction")
| public class TestAction {
| public String sayHi() {
| return "hallo, dude";
| }
| }
|
and modify web.xml file:
| <servlet>
| <servlet-name>TestServlet</servlet-name>
| <servlet-class>actions.TestServlet</servlet-class>
| </servlet>
|
| <servlet-mapping>
| <servlet-name>TestServlet</servlet-name>
| <url-pattern>/testservlet/*</url-pattern>
| </servlet-mapping>
|
| <filter>
| <filter-name>ContextFilter</filter-name>
| <filter-class>org.jboss.seam.web.ContextFilter</filter-class>
| </filter>
|
| <filter-mapping>
| <filter-name>ContextFilter</filter-name>
| <url-pattern>/testservlet/*</url-pattern>
| </filter-mapping>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4112178#4112178
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4112178
More information about the jboss-user
mailing list