A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Servlets
Author
ServletContext AttributeListener again
colin shuker
Ranch Hand
Joined: Apr 11, 2005
Posts: 712
posted
Feb 04, 2007 17:40:00
0
Hi again, can anyone explain why the code below doesn't execute the
attributeAdded(...) method
package pack1; import java.io.*; import java.net.*; import javax.servlet.*; import javax.servlet.http.*; public class ShowFrame extends HttpServlet implements ServletContextAttributeListener { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.getServletContext().setAttribute("name","cat"); String v=(String)this.getServletContext().getAttribute("name"); response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); // TODO output your page here out.println("<html>"); out.println("<head>"); out.println("<title>Servlet ShowFrame</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>V = "+v+"</h1>"); out.println("</body>"); out.println("</html>"); out.close(); } public void attributeAdded(ServletContextAttributeEvent scab) { this.getServletContext().setAttribute("name","chicken"); } public void attributeRemoved(ServletContextAttributeEvent scab) { this.getServletContext().setAttribute("name","chicken"); } public void attributeReplaced(ServletContextAttributeEvent scab) { this.getServletContext().setAttribute("name","chicken"); } }
The
servlet
is included in the web.xml file under <listener> tag.
Thanks for any help
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56207
13
I like...
posted
Feb 04, 2007 20:56:00
0
Please keep the discussion in your original topic.
[
Smart Questions
] [
JSP FAQ
] [
Books by Bear
] [
Bear's FrontMan
] [
About Bear
]
I agree. Here's the link:
http://aspose.com/file-tools
subject: ServletContext AttributeListener again
Similar Threads
ServletContext AttributeListener problem
Problems with getRemoteUser()
ServletContext AttributeListener
My example with ServletContextListener and ServletContextAttrib.
The requested method POST is not allowed for the URL
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter