Re: How to put an object into the application scope from a plugin interface
EL AKARI Mehdi wrote: Hi, I'm writing a struts plugin, and i need to put an object into the application scope. How can i do this. Note that the plugin interface contains the following methods: public void init(ActionServlet servlet, ModuleConfig config) throws javax.servlet.ServletException ; public void destroy() ; thanks Mehdi The easiest way is to use the ActionServlet object to get the ServletContext and push everything in that. The code to do it is pretty simple context = servlet.getServletContext(); context.setAttribute(KEY, object); Then, within a page when you need to get something out you just retrieve the ServletContext and get the attribute back out. Example : context = servlet.getServletContext(); Object retrievedObject = (Object)context.getAttribute(KEY); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Action Design Question
I don't know if this was the 'right' thing to do, but I extended DispatchAction, overrode the execute method to use the hardcoded value rather than looking up a request parameter, and pass that along to dispatchMethod. My actions then inherit from this modified class. You can safely cut out the lines with ServletContext if you don't care about logging invalid parameters. Here's the source /** Overrides the execute method of DispatchAction so that rather than use the parameter to determine which request parameter contains the action to execute, it uses the parameter property directly @param mapping ActionMapping @param form Form associated with action @param HttpServletRequest Current request object @param HttpServletResponse Current response stream **/ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String parameter = mapping.getParameter(); if (parameter == null) { String error = Could not locate the requested forward; ServletContext context = getServlet().getServletContext(); ServletContextWriter output = new ServletContextWriter(context); output.write(error); output.flush(); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, error); return null; } return dispatchMethod(mapping, form, request, response, parameter); } -- Nathan Rogers Library Technology Group 312F Memorial Library 728 State Street 261-1409 Graham Lounder wrote: Hey all, After reading the [Poll] action mappings thread, I now have a couple of design questions. I've got a lot of actions right now and I'd like to group related functionality into one action. I'm thinking of extending the DispatchAction and creating functions to search/view/create/update/delete/load my objects. I'd like to create separate action mappings for each function. My question is, can I hardcode my dispatch parameter in the action mapping or do I have to send it in ever request from the page? Thanks in advance, Graham Graham Lounder - Java Developer CARIS Spatial Components Division [EMAIL PROTECTED] Phone: (506) 458-8533 Fax:(506) 459-3849 NO BINDING CONTRACT WILL RESULT FROM THIS EMAIL UNTIL SUCH TIME AS A WRITTEN DOCUMENT IS SIGNED ON BEHALF OF THE COMPANY. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Struts and synchronization
I am using Struts 1.1 along with the Velocity tools to develop a fairly simple servlet (there are probably going to be no more than twenty actions total) The problem that I am facing is a deadlock situation where Tomcat simply refuses to respond to any new requests and just stalls. I think it may be due to some code in the model where I am using PreparedStatements (which are declared as synchronized). Has anyone else run into a similar problem where the Struts framework takes an unreasonably long time to handle a request due to synchronized methods? Is there any workaround, other than only using Statements in my model? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts and synchronization
Paul Thomas wrote: On 11/08/2003 17:50 Nathan Rogers wrote: Has anyone else run into a similar problem where the Struts framework takes an unreasonably long time to handle a request due to synchronized methods? Is there any workaround, other than only using Statements in my model? I think you're barking up the wrong tree here. You're either getting deadlocks in your database or you've got some dirty code in there that breaks thread safety. I am exploring all the possible things that could cause it to die; here specifically is the scenario that results in responses no longer being handled. The exact configuration for the servlet is Struts 1.1 Velocity Tools 1.0 Tomcat 4.0.2 and Apache 1.3.23 connected using the WarpConnection Oracle 8i backend database 1) Start up a request for an action 2) Reload the servlet using the manager servlet 3) Watch everything crawl to a halt while Warp spins its wheels It very well might have nothing at all to do with the Struts 1.1 framework, but the same things did not happen when using Struts 1.0.2 -- Paul Thomas +--+-+ | Thomas Micro Systems Limited | Software Solutions for the Smaller Business | | Computer Consultants | http://www.thomas-micro-systems-ltd.co.uk | +--+-+ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts and synchronization
The request path for a standard action within my code goes something like this : Struts servlet - action - model - database - model - action - Velocity servlet Here's what I know about each issue you've brought up. #1 - Tomcat is configured to work with the Warp connector. I don't know exactly how this works (if it passes all requests to Tomcat or just the ones registered to a servlet) #2 - I'll have to check with the sysadmin. Where is the number of request processors defined? #3 - I'm using the Jakarta Commons PoolingDataSource. I have used this before without any problems #4 - Something to look into. I'm closing my result sets, statements and connections (which returns them to the pool), but it might not be done in the best way. Mainguy, Mike wrote: The closest I ever came to this sort of problem involved the following: #1 Sending static content (and lots of it) through the servlet engine instead of using the web server. #2 Not having enough request processors and listeners configured. #3 Not using pooling for my connections and killing the DBMS with new connection requests. #4 Not properly closing/releasing my DBMS connections and consuming all available memory. So there you go, everything you should NOT do in a nutshell. Unless you're 100% proof-positive sure that it is a synchronization issue in your database portion, I would take a look at the above issues as potential problem areas. As far as synchronization is concerned, the only thing I can recommend is to be sure you aren't using your ActionServlet or something high in the food chain as your target, otherwise that would seem to cause that sort of a problem. -Original Message- From: Nathan Rogers [mailto:[EMAIL PROTECTED] Sent: Monday, August 11, 2003 12:51 PM To: [EMAIL PROTECTED] Subject: Struts and synchronization I am using Struts 1.1 along with the Velocity tools to develop a fairly simple servlet (there are probably going to be no more than twenty actions total) The problem that I am facing is a deadlock situation where Tomcat simply refuses to respond to any new requests and just stalls. I think it may be due to some code in the model where I am using PreparedStatements (which are declared as synchronized). Has anyone else run into a similar problem where the Struts framework takes an unreasonably long time to handle a request due to synchronized methods? Is there any workaround, other than only using Statements in my model? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This message and its contents (to include attachments) are the property of Kmart Corporation (Kmart) and may contain confidential and proprietary information. You are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on information contained herein is strictly prohibited. Unauthorized use of information contained herein may subject you to civil and criminal prosecution and penalties. If you are not the intended recipient, you should delete this message immediately. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Nathan Rogers Library Technology Group [EMAIL PROTECTED] (608)261-1409 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]