[jboss-user] [JBoss Seam] - Re: Use Seam to generate XML documents

mgrouch do-not-reply at jboss.com
Thu Aug 2 13:24:28 EDT 2007


Still having problems with injection.

I've tried adding 

	<web:context-filter url-pattern="*DataServlet"/>

into components.xml

'database' is not injected and the output from servlet is just
anonymous wrote : Database=null

'database' is injected fine into JSF pages, but not into servlet.

import java.io.IOException;
  | 
  | import javax.servlet.ServletException;
  | import javax.servlet.http.HttpServlet;
  | import javax.servlet.http.HttpServletRequest;
  | import javax.servlet.http.HttpServletResponse;
  | 
  | import org.hibernate.Session;
  | import org.jboss.seam.annotations.In;
  | import org.jboss.seam.annotations.Name;
  | 
  | @Name("DataServlet")
  | public class DataServlet extends HttpServlet {
  | 
  | 
  | 	@In(required=false)
  | 	private Session database;
  | 	
  | 	public DataServlet() {
  | 		super();
  | 	}
  | 
  | 	protected String getAppType() {
  | 		return "application/xml";
  | 	}
  | 
  | 	@Override
  | 	protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
  | 		res.setContentType(getAppType());
  | 		res.getWriter().println("<xml>Database=" + database +  "</xml>");
  | 	}
  | }

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4070219#4070219

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4070219



More information about the jboss-user mailing list