form:link
Weblogic 5.1 refuse to compile the following line: form:link href="quickNews.do?pageSearch=truestockExchange=%= request.getParameter("stockExchange") %stockCode=%= request.getParameter("stockCode") %stockName=%= request.getParameter("stockName") %pPage=%= p %" u%= p %/u/form:linknbsp;nbsp; Is the bug with Weblogic or I cannot use multiple RTE inside the "href" attribute? __ Do You Yahoo!? Yahoo! Photos - Share your holiday photos online! http://photos.yahoo.com/
Re: Help: logic:iterate and form input fields
I have this working now... Here's how I got this working I'm including my BeanUtils.java. Here's how my jsp looks (the form:text does not work as expected...I had to usethe input tag...) TABLE WIDTH=100% border=1TRTH Item Name /thTH Quantity /TH/TR % int count=0; %logic:iterate id="orderlist" name="orderform" property="items" length="2"tr TD input TYPE="TEXT" name="%= "items[" + count + "].itemName" %" value="%= ((OrderItem)orderlist).getItemName() %" / /tdTD input TYPE="TEXT" name="%= "items[" + count++ + "].quantity" %" value="%= ((OrderItem)orderlist).getQuantity() %" / /td /TR/logic:iterate/TABLE The name is the nested and indexed name. The value field needs to be explicitly set to get the value from the bean. The changes I made to BeanUtils.java is I commented out this code in public static void populate(Object bean, String prefix, String suffix, HttpServletRequest request) /* CK: int subscript = stripped.lastIndexOf("["); if (subscript = 0) // Remove subscript expression stripped = stripped.substring(0, subscript); CK: */ This keeps the indexed part of the name And then in public static void populate(Object bean, Hashtable properties) Added this code // Check to see if the name is nested or indexed - then use PropertyUtils.setProperty int indexed = name.lastIndexOf("["); int nested = name.lastIndexOf("."); if ((indexed = 0) || (nested = 0)) {try { PropertyUtils.setProperty( bean, name, Array.get(value, 0));}catch( java.lang.NoSuchMethodException e ) {} continue; } To handle the nested and indexed names by calling PropertyUtils.setProperty... Good luck, -Chandan Kulkarni. -Original Message-From: Mishkin Berteig [EMAIL PROTECTED]To: [EMAIL PROTECTED] [EMAIL PROTECTED]Cc: Chandan Kulkarni [EMAIL PROTECTED]Date: Thursday, January 04, 2001 10:43 PMSubject: Re: Help: logic:iterate and form input fieldsActually, I think I can add some clarification to this issue as I am encountering what I see as a similar problem. The basic goal is to create a form where there are a variable number of entries, all of which are the same type. The number of entries is determined at run-time, for example from rows in a database table. An example scenario would look something like this. Your Shopping Cart: ITEM: QUANTITY: Pencil 1___ Eraser 1___ Cheese 1___ (The quantities are text fields.) The list of items is generated at run-time from the things a person has clicked into their shopping cart, and the quantities are set at check-out time (by the user). The problem is that the iterate and form tags dont seem to work together for indexed properties. This is partially a problem with the underlying html. Each text field in a form needs a different name. In order to have these fields correspond to a specific index value in an indexed property, the names of the fields need to be parsed. The html might look something like this: form ... table tr tdITEM:/tdtdQuantity/td /tr tr tdPencil/tdtdinput type="text" name="item000" value="1"/td /tr tr tdPencil/tdtdinput type="text" name="item001" value="1"/td /tr tr tdPencil/tdtdinput type="text" name="item002" value="1"/td /tr /table ... /form When the submit button was hit, the request parameters would be parsed. I have just started working on this problem. Mishkin. Chandan Kulkarni wrote: Yes...same idea... -Original Message- From: Ted Husted [EMAIL PROTECTED] To: Struts List [EMAIL PROTECTED] Date: Wednesday, December 27, 2000 10:36 AM Subject: Re: Help: logic:iterate and form input fields Are you trying to do something like this order form (Javascript)https://public.wxxi.org/schedules/fm/voice-order.htmThis only shows one item, but the idea is that there would be one line for each item in a small inventory. -- Ted Husted, Husted dot Com, Fairport NY USA. -- Custom Software ~ Technical Services. -- Tel 716 425-0252; Fax 716 223-2506. -- http://www.husted.com/ /* * $Header: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/util/BeanUtils.java,v 1.15 2000/11/13 17:31:05 mschachter Exp $ * $Revision: 1.15 $ * $Date: 2000/11/13 17:31:05 $ * * * * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *
Resource bundle and collection questions
Hello, I've just started to take a look at the framework, and I like what I see!!! Going through the user guide and some of the code(v0.5), I've a couple of questions: 1. It seems that in general the Vector and Hashtable classes are used. Are there any particular reason why these are used as supposed to the corresponding ArrayList and Hashmap? Will I run into synchronization issues if I replace with the unsynchronized ones? 2. In the Internationalized Messages section of the user guide it talks about "the resource bundle for the application". I was thinking of using several smaller resource bundles for the application, for example one for each view. What is the best way(if possible) to acheive this within this framework. Thanks, Roger Kjensrud
Re: Business Logic Beanies
A kind soul sent me this link to a Powered-by-Struts auction application, BrewTrade by Java-Genius - http://www.java-genius.com/ that uses a neat mechanism to abstract a database result into a generic list of fields (KeyValuePairs), which can then be used to populate a data bean. The method that gathers the database results packages each value with its column name, which the data bean can then use to match it up with one of its own properties. This comes very close to turning a result into an array of standard Java Beans, using the metadata to generate the "introspective" layer. Has anyone seen a type of factory that would do this; take a resultset and spit out a list of JavaBeans, where the column names automatically become "get" accessors.
[Q] struts:link with forward attribute on WebLogic 6.0
I try to forward the request in a jsp page as follows: %@ page language="java" % %@ taglib uri="/WEB-INF/struts.tld" prefix="struts" % HTML struts:link forward="ibohome"/struts:link /HTML I have the "ibohome" defined in the action.xml as follows, !-- Global Forward Declarations -- forward name="ibohome" path="/generic.do?jsp=/iBiomaticsPortal/MainContents.jsp"/ However, I got the following exception when I am trying to run it (I got the same exception if I replace "success" with "ibohome"). Could not deserialize context attribute java.io.NotSerializableException: org.apache.struts.action.ActionForwards at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1148) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:366) at weblogic.servlet.internal.AttributeWrapper.getObject(AttributeWrapper.ja va:71) at weblogic.servlet.internal.WebAppServletContext.getAttribute(WebAppServle tContext.java:211 ) at weblogic.servlet.jsp.PageContextImpl.getAttribute(PageContextImpl.java:1 64) at org.apache.struts.taglib.LinkTag.hyperlink(LinkTag.java:348) at org.apache.struts.taglib.LinkTag.doStartTag(LinkTag.java:270) at jsp_servlet._ibiomaticsportal._struts_test_zli._jspService(_struts_test_ zli.java:87) at weblogic.servlet.jsp.JspBase.service(JspBase.java:27) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl. java:208) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl. java:244) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServl etContext.java:11 27) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl. java:1529) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120) Jan 5, 2001 9:21:50 AM EST Error HTTP [WebAppServletContext(8068452,DefaultWebApp_myserver)] Root cause of ServletException javax.servlet.jsp.JspException: Cannot locate forwards mapping table at org.apache.struts.taglib.LinkTag.hyperlink(LinkTag.java:351) at org.apache.struts.taglib.LinkTag.doStartTag(LinkTag.java:270) at jsp_servlet._ibiomaticsportal._struts_test_zli._jspService(_struts_test_ zli.java:87) at weblogic.servlet.jsp.JspBase.service(JspBase.java:27) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl. java:208) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl. java:244) at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServl etContext.java:11 27) at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl. java:1529) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120) == What I am trying to do is that when the index.html or index.jsp is invoked, it will forward the request to my main page without user to type anything. Any other approach I can take. Thanks, Zhiyong Li Portal Development iBiomatics LLC , a SAS Company (919) 653-2746 [EMAIL PROTECTED]
RE: help, please!
1. In tomcat 3.2 template:put work properly, but with resin 1.2.1 body of this tag not processed. I also had problems with the recently updated template:put tag under Resin (and had instead been using your template:extput, Oleg) but the very latest Resin snapshot release (1-2-2001) seems to have fixed some bugs relating to tag body content; I'm now able to use the stock template:put tag with Resin. Andy Boyko [EMAIL PROTECTED]
RE: Template layout file with an include (bean or jsp) to a jsp with a form. (there are many tomcat developer here also i believe)
Hi, I thought i shall be smart, i developed my own: IncludeServletResponse that implements HttpServletResponse) That one routes everything to the base servlet response of the pagecontext except the outputstream ones: The getOutputStream() returns not the default one of the first Response but my own implementation but now the bug of Tomcat??: IncludeResponse iResponse = new IncludeResponse((HttpServletResponse)pageContext.getResponse()); RequestDispatcher rd= pageContext.getServletContext().getRequestDispatcher(_sPage); rd.forward(pageContext.getRequest(), iResponse); iResponse is my own implentation. The RequestDispatcher interface wants only a ServletResponse (and a ServletRequest) It compiles fine so how is it possible that the RequestDispatcher throws a ClassCastException inside itself? What kind of ServletResponse does it wants? Johan Compagner -Original Message- From: Johan Compagner [mailto:[EMAIL PROTECTED]] Sent: Friday, January 05, 2001 4:05 PM To: Struts-User Subject: Template layout file with an include (bean or jsp) to a jsp with a form. Hi, I will ask the basic question first so that you don't have to read the whole email: So is there no way to use the same request over 2 or more jsp files that are nested in each other? Now my test case: I have a template jsp file that has all the layout of my site. in the right left corner will al the dynamic data. like this: // tag libs includes form:html locale="true" head titlebean:message key="index.title"//title /head body bgcolor="#fce8a0" topmargin="0" leftmargin="0" table width="100%" border="0" height="123" cellpadding="0" cellspacing="0" bgcolor="#0066ff" tr td // standard layout of my site // jadajadajadajada /td // The include logic. logic:present name="%= JSP_INCLUDE_KEY %" scope="request" bean:include id="subpage" name="%= (String)request.getAttribute(Constants.JSP_INCLUDE_KEY) %"/ %= subpage % /logic:present logic:notPresent name="%= Constants.JSP_INCLUDE_KEY %" scope="request" bean:include id="subpage" name="/index.jsp"/ %= subpage % /logic:notPresent /tr /table /body /form:html This template file is always the ActionForward that i return as the next page to see after this action, something in the perform method of a Action: request.setAttribute(Constants.JSP_INCLUDE_KEY, mapping.findForward("pensioen3a").getPath()); return mapping.findForward("template"); The nicest thing about this is that if i want to change something of my site i only have to edit one file and every page/view is changed also like the logon page or the pages with the forms. But now my problem. An Action is mostly triggerd by the subpage (where the form is in). That Action is testing the input (some validation) if that goes wrong that a ACtionError is made and is attached to the request. But when i forward it (to the same page) i forward it to the template again and that template includes the page with the form. But the include generates another request for that subpage so my ActionErrors object and other objects that i stored in the request aren't there!! I also do this in te validate() of a Form: String fromPage = request.getParameter("frompage"); mapping.setInput(mapping.findForward("template").getPath()); request.setAttribute(Constants.JSP_INCLUDE_KEY, mapping.findForward(fromPage).getPath()); So that when there are errors returned it knows that the input is the template and the include is the same page it come's from. But this also doesn't work. I can't be the only one with this problem. Are nobody else using subpages where the form/inputs are in an another one that is the standard layout page? I thought to be smart and made my own include tag: public int doStartTag() throws JspException { try { RequestDispatcher rd= pageContext.getServletContext().getRequestDispatcher(_sPage); rd.forward(pageContext.getRequest(), pageContext.getResponse()); } catch(Exception e) { throw new JspException(e.getMessage()); } return SKIP_BODY; } But the problem is then that the subpage (the _sPage string) is displayed first, above the main page instead of in the main page. Why is this? Because when i walk through the code then i see the main page that writes to the output and then the subpage and then the main page again. I think this has something to do with flushing ect. But if i flush first (right above the RequestDispatcher line i do this: pageContext.getOut().flush(); Then i get the main page on top again but an error in the place where the subpage should be: Location: /postbank/template.jsp Internal Servlet Error: javax.servlet.ServletException: Cannot forward as OutputStream or Writer has already
RE: Re[2]: help, please!
I try to use 2001-01-05 version from CVS - put tag has strange behavior. Do you mean the CVS version of Resin, or of Struts? It's Resin that had the problem, circa 1.2.1... After upgrading Resin to 2001-01-03, and using the current CVS version of struts, I am able to use template:put in all three ways of supplying its content. Andy Boyko [EMAIL PROTECTED]
Re: Help: logic:iterate and form input fields
How does your orderform bean look? What are the method signatures for the items property? Thanks, Mishkin. Chandan Kulkarni wrote: I have this working now...Here's how I got this workingI'm including my BeanUtils.java.Here's how my jsp looks (the form:text> does not work as expected...I had to use the input tag...) TABLE WIDTH=100% border=1> TR> TH> Item Name /th> TH> Quantity /TH> /TR>% int count=0; %> logic:iterate id="orderlist" name="orderform" property="items" length="2"> tr> TD> input TYPE="TEXT" name="%= "items[" + count + "].itemName" %>" value="%= ((OrderItem)orderlist).getItemName() %>" /> /td> TD> input TYPE="TEXT" name="%= "items[" + count++ + "].quantity" %>" value="%= ((OrderItem)orderlist).getQuantity() %>" /> /td> /TR> /logic:iterate> /TABLE> The name is the nested and indexed name. The value field needs to be explicitly set to get the value from the bean.The changes I made to BeanUtils.java isI commented out this code inpublic static void populate(Object bean, String prefix, String suffix, HttpServletRequest request) /* CK: int subscript = stripped.lastIndexOf("["); if (subscript >= 0) // Remove subscript expression stripped = stripped.substring(0, subscript); CK: */ This keeps the indexed part of the nameAnd then in public static void populate(Object bean, Hashtable properties)Added this code // Check to see if the name is nested or indexed - then use PropertyUtils.setProperty int indexed = name.lastIndexOf("["); int nested = name.lastIndexOf("."); if ((indexed >= 0) || (nested >= 0)) { try { PropertyUtils.setProperty( bean, name, Array.get(value, 0)); } catch( java.lang.NoSuchMethodException e ) { } continue; } To handle the nested and indexed names by calling PropertyUtils.setProperty...Good luck, -Chandan Kulkarni. S/MIME Cryptographic Signature
Re: form:link
Wong Kok Wai wrote: Weblogic 5.1 refuse to compile the following line: form:link href="quickNews.do?pageSearch=truestockExchange=%= request.getParameter("stockExchange") %stockCode=%= request.getParameter("stockCode") %stockName=%= request.getParameter("stockName") %pPage=%= p %" u%= p %/u/form:linknbsp;nbsp; Is the bug with Weblogic or I cannot use multiple RTE inside the "href" attribute? Note that you are trying to use double quotes nested inside double quotes, which will create syntax errors in the resulting Java code. It is also not legal to make PART of an attribute a runtime expression -- it is all or nothing. Try this: %= String temp = ". the expression above ..."; % form:link href="%= temp %"/ Craig
Re: Template layout file with an include (bean or jsp) to a jsp with a form. (there are many tomcat developer here also i believe)
Johan Compagner wrote: Hi, I thought i shall be smart, i developed my own: IncludeServletResponse that implements HttpServletResponse) On a servlet 2.2 container, this is not legal -- the request and response arguments that you pass on to a RequestDispatcher *must* be the ones you originally received. Many servlet containers (such as Tomcat 3.2) rely on this in order to cast the object back to their own internal implementation class. On a servlet 2.3 container (such as Tomcat 4.0), you can do this, as long as your class does an "extends HttpServletResponseWrapper". Craig McClanahan
Re: Template tags ?
"Laufer, Michael" wrote: Hi, I'm already programming a couple of weeks with Struts and I'm totally fascinated about it, but I still haven't figured out, when I could, should ... use the template-tags of the Struts framework. Could anybody give me a short introduction,maybe with a short example, how tu use these tags. There is a small example webapp that uses these tags included with Struts. Simply deploy the "webapps/struts-template.war" file in your servlet container, and give it a try. Thanks in advance. Michael Craig
Re: Resource bundle and collection questions
Roger Kjensrud wrote: Hello, I've just started to take a look at the framework, and I like what I see!!! Going through the user guide and some of the code(v0.5), I've a couple of questions: 1. It seems that in general the Vector and Hashtable classes are used. Are there any particular reason why these are used as supposed to the corresponding ArrayList and Hashmap? Will I run into synchronization issues if I replace with the unsynchronized ones? At the time Struts 0.5 was released, the consensus of the community was that we still needed to run on JDK 1.1 platforms. Since then, the community consensus has shifted, and Struts 1.0 (to be released very soon -- I would recommend you do any new development based on a recent nightly snapshot rather than Struts 0.5) requires Java2. Previous uses of Vector and Hashtable have generally been migrated to ArrayList and HashMap. In general, using the unsynchronized collection classes in a servlet based application requires you to be aware of whether it is possible to access that collection from multiple threads at the same time or not. If not (for example, a local variable inside a method that is never passed to external code), it is safe to code without synchronizing. So, there is no general answer to this question -- you have to look at each situation individually. 2. In the Internationalized Messages section of the user guide it talks about "the resource bundle for the application". I was thinking of using several smaller resource bundles for the application, for example one for each view. What is the best way(if possible) to acheive this within this framework. The current MessageResources implementation assumes that there is only one bundle for the entire app -- primarily for simplicity (because the message tag knows where to look for it, and you don't have to tell it every time). Alternatives: * Manually load your own MessageBundle implementations as servlet context attributes, and then use the "bundle" attribute of the message bean on every call to tell which bundle to use. * Maintain the different bundle files separately in your source code directories, but have a script as part of your build procedure that combines them into the single bundle that Struts expects. Thanks, Roger Kjensrud Craig McClanahan
RE: [Q] struts:link with forward attribute on WebLogic 6.0
Do you have a quick answer to my last question in my previous note? The question is included below. What I am trying to do is that when the index.html or index.jsp is invoked, it will forward the request to my main page without user to type anything. The main page is a jsp which will be invoked by one of the actions I will write. (I think what I need is to directly invoke the Struts servlet with certain parameters without using struts:link). Any other approach I can take. Thanks, Zhiyong -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Friday, January 05, 2001 12:40 PM To: [EMAIL PROTECTED] Subject: Re: [Q] struts:link with forward attribute on WebLogic 6.0 Zhiyong Li wrote: I try to forward the request in a jsp page as follows: %@ page language="java" % %@ taglib uri="/WEB-INF/struts.tld" prefix="struts" % HTML struts:link forward="ibohome"/struts:link Note that you'll probably want some text in between the beginning and ending tags, so you can actually see the hyperlink on the browser screen. /HTML I have the "ibohome" defined in the action.xml as follows, !-- Global Forward Declarations -- forward name="ibohome" path="/generic.do?jsp=/iBiomaticsPortal/MainContents.jsp"/ However, I got the following exception when I am trying to run it (I got the same exception if I replace "success" with "ibohome"). Could not deserialize context attribute java.io.NotSerializableException: org.apache.struts.action.ActionForwards WebLogic 6.0 currently has a restriction that all servlet context attributes in a webapp have to be Serializable (not just session attributes). I've been going through the various objects that Struts itself creates, and ActionForwards (among others) was recently made Serializable -- you should be able to do this with a very recent nightly build. NOTE: The Struts example application still won't work, though -- it uses a context attribute that is not serializable, so it won't work correctly on this platform. Craig McClanahan
FW: Using Struts with WebLogic 5.1 - JSP Problem
I am able to view struts-documentation. war ( a simple HTML page ) with WebLogic, but get the following error when I try to view struts-example.war: ServletContext-myapp problem defining JSP class java.lang.NullPointerException at weblogic.servlet.jsp.OneOffJspLoader.init(JspStub.java:420) at weblogic.servlet.jsp.JspStub.getClassLoader(JspStub.java:107) Has anyone else had problems defining the same JSP class with the Struts example .war files in WebLogic 5.1? Thanks, Steven
Possibly Stupid Question
I want to generate a link tag for a page which takes three parameters. The values of the parameter come from a bean which is available to the page. The end result should look something like this: a href="foo.do?parm1=val1parm2=val2parm3=val3"Link/a The values for val1, val2 and val3 come from a bean which happens to be the current bean for an iterate tag. In other words, I'm going to have a table of items and each cell in the table is going to have unique values for the parameters. What is the easiest way to do this using struts? I've used the form:link tag before, but I think I can only pass one parameter with this tag. I've tried using snippets of java code ("%= bean.getFoo() %" for example) but this code ended up being quite verbose because I had to cast "bean" to the proper type before I could call "getFoo()". I'm thinking there must be a cleaner way to handle this situation. The only other way I've thought about would be to have the bean answer an "optionsString" as one of its properties, but I would rather not have that code in my bean. Thanks for any suggestions.
Re: [Q] struts:link with forward attribute on WebLogic 6.0
Zhiyong Li wrote: Do you have a quick answer to my last question in my previous note? The question is included below. What I am trying to do is that when the index.html or index.jsp is invoked, it will forward the request to my main page without user to type anything. The main page is a jsp which will be invoked by one of the actions I will write. (I think what I need is to directly invoke the Struts servlet with certain parameters without using struts:link). Any other approach I can take. If you want to forward totally transparently, doesn't jsp:forward do the trick? Thanks, Zhiyong Craig
Re: struts generating progress messages
Kitching Simon wrote: Hi, I currently have a model-1 web application ie in which the .jsp pages are responsible for invoking the business logic. I am planning to move the webapp to struts, for all the obvious and traditional reasons. However, there is one nice feature of the current code that I can't see how to perform inside an MVC framework like struts: On submitting a particular form, there is a sequence of 4 operations to perform, each of which takes somewhere between 5 and 30 seconds to perform. Currently, what is done is to generate an almost complete HTML page, and force it to be flushed to the browser; as each long-duration step starts and completes, a fragment of page containing CSS-positioned html/ javascript is flushed to the browser. The effect is very nice - a list of the steps appears on the screen, an hourglass appears next to each step as it starts, and a tick or error message appears next to each one as it completes. Does anyone have any idea how to generate the same sort of effect (essentially alternating between business logic and presentation output) in struts? As you've gathered, a model 2 approach is not amenable to using flushing to show progress. A strategy that might work better is something like this, in the initial Action that starts all of the work: * Fire off a background thread to do the long-duration work. * Give this thread access to the user's session, so it can update a status variable when it is done * Return a "work in progress .. click here to check for completion" page, which returns to the same action * When the action is entered, it will check to see that a background thread is currently running, so it will display another "work in progress" page, or the final results, depending on what's been done so far. * When the background thread completes its work, it updates the final status and exits. Variations on the theme: * The status variable need not be binary -- for a multiple stage background operation, it could be a state identifier, or a percentage completed, or something like that, so you can be more descriptive on the "in progress" page. * You might want to generate a meta refresh tag on the "in progress" page, so that the user doesn't have to remember to hit the link. Thanks in advance, Simon Craig
Re: Possibly Stupid Question
James Howe wrote: I want to generate a link tag for a page which takes three parameters. The values of the parameter come from a bean which is available to the page. The end result should look something like this: a href="foo.do?parm1=val1parm2=val2parm3=val3"Link/a The values for val1, val2 and val3 come from a bean which happens to be the current bean for an iterate tag. In other words, I'm going to have a table of items and each cell in the table is going to have unique values for the parameters. What is the easiest way to do this using struts? I've used the form:link tag before, but I think I can only pass one parameter with this tag. I've tried using snippets of java code ("%= bean.getFoo() %" for example) but this code ended up being quite verbose because I had to cast "bean" to the proper type before I could call "getFoo()". I'm thinking there must be a cleaner way to handle this situation. The only other way I've thought about would be to have the bean answer an "optionsString" as one of its properties, but I would rather not have that code in my bean. The Struts 1.0 version of the form:link tag lets you use the "name" (or "name" and "property") attributes to identify a Map that contains request parameters to be added to the end of the request URI. You might find it useful for this purpose. Thanks for any suggestions. Craig
RE: struts generating progress messages
-Original Message- From: Craig R. McClanahan [SMTP:[EMAIL PROTECTED]] Sent: Friday, January 05, 2001 8:28 PM To: [EMAIL PROTECTED] Subject: Re: struts generating progress messages Kitching Simon wrote: Hi, I currently have a model-1 web application ie in which the .jsp pages are responsible for invoking the business logic. I am planning to move the webapp to struts, for all the obvious and traditional reasons. However, there is one nice feature of the current code that I can't see how to perform inside an MVC framework like struts: On submitting a particular form, there is a sequence of 4 operations to perform, each of which takes somewhere between 5 and 30 seconds to perform. Currently, what is done is to generate an almost complete HTML page, and force it to be flushed to the browser; as each long-duration step starts and completes, a fragment of page containing CSS-positioned html/ javascript is flushed to the browser. The effect is very nice - a list of the steps appears on the screen, an hourglass appears next to each step as it starts, and a tick or error message appears next to each one as it completes. Does anyone have any idea how to generate the same sort of effect (essentially alternating between business logic and presentation output) in struts? As you've gathered, a model 2 approach is not amenable to using flushing to show progress. A strategy that might work better is something like this, in the initial Action that starts all of the work: * Fire off a background thread to do the long-duration work. * Give this thread access to the user's session, so it can update a status variable when it is done * Return a "work in progress .. click here to check for completion" page, which returns to the same action * When the action is entered, it will check to see that a background thread is currently running, so it will display another "work in progress" page, or the final results, depending on what's been done so far. * When the background thread completes its work, it updates the final status and exits. Variations on the theme: * The status variable need not be binary -- for a multiple stage background operation, it could be a state identifier, or a percentage completed, or something like that, so you can be more descriptive on the "in progress" page. * You might want to generate a meta refresh tag on the "in progress" page, so that the user doesn't have to remember to hit the link. Thanks in advance, Simon Craig [Kitching Simon] Thanks very much for your reply! I don't like the link or refresh idea much, but your suggestion of a "background thread" triggered another idea for me... How about the action starts a threaded business class, then forwards to the presentation page. This business class has methods waitForStep1(), waitForStep2(), etc, which when called do a wait() on a member variable. As the thread completes each step, it calls notify() on the corresponding member variable. The presentation page generates flushes output, then calls waitForStep1(), thereby blocking. When the function returns, it outputs the results, and calls waitForStep2(), etc. In effect, we have an action "piping" results to a presentation page that is running in parallel with it. Do you think this will work? And do you think that this might be worth making part of the framework? It sounds quite tidy to me Thanks again, Simon
Re: struts generating progress messages
Kitching Simon wrote: Hi, I currently have a model-1 web application ie in which the .jsp pages are responsible for invoking the business logic. I am planning to move the webapp to struts, for all the obvious and traditional reasons. However, there is one nice feature of the current code that I can't see how to perform inside an MVC framework like struts: On submitting a particular form, there is a sequence of 4 operations to perform, each of which takes somewhere between 5 and 30 seconds to perform. Currently, what is done is to generate an almost complete HTML page, and force it to be flushed to the browser; as each long-duration step starts and completes, a fragment of page containing CSS-positioned html/ javascript is flushed to the browser. The effect is very nice - a list of the steps appears on the screen, an hourglass appears next to each step as it starts, and a tick or error message appears next to each one as it completes. Does anyone have any idea how to generate the same sort of effect (essentially alternating between business logic and presentation output) in struts? Thanks in advance, Simon How about creating a separate thread to perform the tasks, and forwarding immediately to the jsp page in your main thread. Create an object which can wait for the tasks to complete, and attach that object to the request before forwarding. As an example, create a TaskMonitor (sample code below; this code is untested, and I usually don't program threads so don't trust it to work without some scrutiny). Task thread. Create a thread to perform your tasks and give it a reference to this monitor. Each time a task is complete, call monitor.taskComplete(taskid). Main thread. Attach monitor to request. Forward to jsp. The jsp can call monitor.waitForTask(taskid) for each task in sequence. public class TaskMonitor { boolean[] taskComplete; public TaskMonitor(int taskCount) { taskComplete = new boolean[taskCount]; } public synchronized waitForTask(int taskid) { if (taskid 0 || taskid = taskComplete.length || taskComplete[taskid]) return; while(true) { try { wait(); } catch(InterruptedException ie) { } if (taskComplete[taskid]) return; } } public synchronized taskComplete(int taskid) { if (taskid 0 taskid taskComplete.length) { taskComplete[taskid] = true; notifyAll(); } } }
Re: Problem with Logic:Iterate
Dennis wrote: Hello, I'm new to struts, and trying to kick the tires a little but I'm having a problem using the iterate tag. I have a Bean called DataObjects that contains a Vector called 'objects'. The vector contains beans with a single member variable called 'name'. In the Action class, I use request.setAttribute("dos", objects) to make the bean visible. When I use the following in my .jsp file, I get an error stating "javax.servlet.ServletException: No bean found for attribute key row". It must be something simple, but I can't seem to find the problem. There was a bug in the iterate tag a couple of weeks ago, where it would not actually create the "row" variable for you. This has been fixed with recent nightly builds -- could you try it again with last night's? Craig
Re: Logic Present Tag
David Winterfeldt wrote: Role was recently added to the logic:present tag (thanks), but it would be nice if there was some way to check for multiple roles. Either by comma delimiting the String or passing in a String[], Collection, or anything else if someone can think of a better way. You can do an "and" by nesting: logic:present role="admin" logic:present role="manager" User is an admin and a manager /logic:present /logic:present so I assume you are talking about implementing an "or" check, right? David Winterfeldt Craig
RE: struts generating progress messages
Thanks, Jim! A reply in about 5 minutes, complete with pseudo-code - I'm impressed :-) As you probably saw from my reply to Craig, a similar idea occurred to me - after the idea of creating a separate thread to perform business processing was suggested. I like your idea of a generic TaskMonitor "synchronizer" object that essentially mediates between the action and the presentation slightly better than my idea of building it into the class doing the actions too - the TaskMonitor could even be a standard utility class, with it's array of Booleans (if I understand your code right). All the action page need to agree on is a set of constants (probably best defined in an interface) to use as the task ids... Anyway, plenty to ponder. Cheers thanks again, Simon -Original Message- From: Jim Newsham [SMTP:[EMAIL PROTECTED]] Sent: Friday, January 05, 2001 8:36 PM To: [EMAIL PROTECTED] Subject: Re: struts generating progress messages Kitching Simon wrote: Hi, I currently have a model-1 web application ie in which the .jsp pages are responsible for invoking the business logic. I am planning to move the webapp to struts, for all the obvious and traditional reasons. However, there is one nice feature of the current code that I can't see how to perform inside an MVC framework like struts: On submitting a particular form, there is a sequence of 4 operations to perform, each of which takes somewhere between 5 and 30 seconds to perform. Currently, what is done is to generate an almost complete HTML page, and force it to be flushed to the browser; as each long-duration step starts and completes, a fragment of page containing CSS-positioned html/ javascript is flushed to the browser. The effect is very nice - a list of the steps appears on the screen, an hourglass appears next to each step as it starts, and a tick or error message appears next to each one as it completes. Does anyone have any idea how to generate the same sort of effect (essentially alternating between business logic and presentation output) in struts? Thanks in advance, Simon How about creating a separate thread to perform the tasks, and forwarding immediately to the jsp page in your main thread. Create an object which can wait for the tasks to complete, and attach that object to the request before forwarding. As an example, create a TaskMonitor (sample code below; this code is untested, and I usually don't program threads so don't trust it to work without some scrutiny). Task thread. Create a thread to perform your tasks and give it a reference to this monitor. Each time a task is complete, call monitor.taskComplete(taskid). Main thread. Attach monitor to request. Forward to jsp. The jsp can call monitor.waitForTask(taskid) for each task in sequence. public class TaskMonitor { boolean[] taskComplete; public TaskMonitor(int taskCount) { taskComplete = new boolean[taskCount]; } public synchronized waitForTask(int taskid) { if (taskid 0 || taskid = taskComplete.length || taskComplete[taskid]) return; while(true) { try { wait(); } catch(InterruptedException ie) { } if (taskComplete[taskid]) return; } } public synchronized taskComplete(int taskid) { if (taskid 0 taskid taskComplete.length) { taskComplete[taskid] = true; notifyAll(); } } }
Action Path Problem when Doc Base used
All my Struts actions work OK until I inserted base href='http://java' in my HTML document. This doc base caused form:link page="/logoff.do"bean:message key="mainMenu.logoff"//form:link to link to http://java/logoff.do and of course Struts action servlet does not know how to handle this. Any tricks? Deping
Re: Logic Present Tag
Yes, I did mean or. David --- "Craig R. McClanahan" [EMAIL PROTECTED] wrote: David Winterfeldt wrote: Role was recently added to the logic:present tag (thanks), but it would be nice if there was some way to check for multiple roles. Either by comma delimiting the String or passing in a String[], Collection, or anything else if someone can think of a better way. You can do an "and" by nesting: logic:present role="admin" logic:present role="manager" User is an admin and a manager /logic:present /logic:present so I assume you are talking about implementing an "or" check, right? David Winterfeldt Craig __ Do You Yahoo!? Yahoo! Photos - Share your holiday photos online! http://photos.yahoo.com/
Possibly Stupid Question
I want to generate a link tag for a page which takes three parameters. The values of the parameter come from a bean which is available to the page. The end result should look something like this: a href="foo.do?parm1=val1parm2=val2parm3=val3"Link/a The values for val1, val2 and val3 come from a bean which happens to be the current bean for an iterate tag. In other words, I'm going to have a table of items and each cell in the table is going to have unique values for the parameters. What is the easiest way to do this using struts? I've used the form:link tag before, but I think I can only pass one parameter with this tag. I've tried using snippets of java code ("%= bean.getFoo() %" for example) but this code ended up being quite verbose because I had to cast "bean" to the proper type before I could call "getFoo()". I'm thinking there must be a cleaner way to handle this situation. The only other way I've thought about would be to have the bean answer an "optionsString" as one of its properties, but I would rather not have that code in my bean. Thanks for any suggestions.
Re: [Q] struts:link with forward attribute on WebLogic 6.0
Zhiyong Li wrote: What is the syntax? I tried, jsp:forward page="/servlet/action/generic.do" / jsp:forward page="/action/generic.do" / None of them work. ("generic" is a action defined in the action.xml). It should be a context-relative path to your action or page. For example, if you use the normal style of mapping the Struts servlet to "*.do", it would be jsp:forward page="/generic.do"/ NOTE: The form:base tag mentioned earlier is only in Struts 1.0 -- I don't think it was in Struts 0.5. Zhiyong Craig -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Friday, January 05, 2001 2:23 PM To: [EMAIL PROTECTED] Subject: Re: [Q] struts:link with forward attribute on WebLogic 6.0 Zhiyong Li wrote: Do you have a quick answer to my last question in my previous note? The question is included below. What I am trying to do is that when the index.html or index.jsp is invoked, it will forward the request to my main page without user to type anything. The main page is a jsp which will be invoked by one of the actions I will write. (I think what I need is to directly invoke the Struts servlet with certain parameters without using struts:link). Any other approach I can take. If you want to forward totally transparently, doesn't jsp:forward do the trick? Thanks, Zhiyong Craig
Re: ActionForm and isCancelled...
"Steven D. Wilkinson" wrote: I had a issue with a form and the cancel button. I'm using the cancel button from the submit tag library in my jsp: form:submit property="cancel" bean:message key="button.cancel"/ /form:submit Have you looked at the form:cancel tag? It creates a cancel button with a field name that the Struts controller servlet recognizes. When I display the Form and the user wants to Cancel I have to look for the cancel button parameter using the same technique as the isCancelled(HttpServletRequest request) method within the Action class. Is this common enough that some could add an isCancelled(HttpServletRequest request) within the ActionForm class? My dilemma is that I don't want to perform any validation if the user presses the cancel button. Here is what I did to my ActionForm class. If you use form:cancel and the user presses that button, Struts will recognize this and never call the validate() method of your ActionForm. It will simply pass control on to your Action, where you can check for this by calling: if (isCancelled(request)) { ... do something ... } Craig
RE: [Q] struts:link with forward attribute on WebLogic 6.0
That fixed problem. I actually need to add extra path to "/generic.do", but the idea is correct. -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Friday, January 05, 2001 4:21 PM To: [EMAIL PROTECTED] Subject: Re: [Q] struts:link with forward attribute on WebLogic 6.0 Zhiyong Li wrote: What is the syntax? I tried, jsp:forward page="/servlet/action/generic.do" / jsp:forward page="/action/generic.do" / None of them work. ("generic" is a action defined in the action.xml). It should be a context-relative path to your action or page. For example, if you use the normal style of mapping the Struts servlet to "*.do", it would be jsp:forward page="/generic.do"/ NOTE: The form:base tag mentioned earlier is only in Struts 1.0 -- I don't think it was in Struts 0.5. Zhiyong Craig -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Friday, January 05, 2001 2:23 PM To: [EMAIL PROTECTED] Subject: Re: [Q] struts:link with forward attribute on WebLogic 6.0 Zhiyong Li wrote: Do you have a quick answer to my last question in my previous note? The question is included below. What I am trying to do is that when the index.html or index.jsp is invoked, it will forward the request to my main page without user to type anything. The main page is a jsp which will be invoked by one of the actions I will write. (I think what I need is to directly invoke the Struts servlet with certain parameters without using struts:link). Any other approach I can take. If you want to forward totally transparently, doesn't jsp:forward do the trick? Thanks, Zhiyong Craig
Re: Action Path Problem when Doc Base used
Craig, Thanks for your suggestion. But I HAVE to use doc base for all my HTML pages under a certain template. This template has numourous pictures links, company logos, JavaScript libraries, et al, which are already written by someone else, stored in an organized directory structure in another server (i.e. http://java). In this template I inserted a few special tags (e.g. #FAQS/) for my JSP pages to replace with relevant HTMLs. I could setup a String servAddr for the real server address and use a href="%=servAddr%/logoff.do"bean:message key="mainMenu.logoff"//a to replace form:link page="/logoff.do"bean:message key="mainMenu.logoff"//form:link and it now correctly links to http://localhost:8080/logoff.do. But form:link page="%=servAddr%/logoff.do"bean:message key="mainMenu.logoff"//form:link links to http://java/%=servAddr%/logoff.do which is wierd. In other words, it seems that my Tomcat does not translate %=xxx% tag before taglib calls. Anyway, it's mostly solved for myself. Deping - Original Message - From: "Craig R. McClanahan" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, January 05, 2001 6:42 PM Subject: Re: Action Path Problem when Doc Base used Deping Chian wrote: All my Struts actions work OK until I inserted base href='http://java' in my HTML document. This doc base caused form:link page="/logoff.do"bean:message key="mainMenu.logoff"//form:link to link to http://java/logoff.do and of course Struts action servlet does not know how to handle this. Well, the smart ass answer would be "so don't do that" :-) What the base tag does is tells your browser to resolve relative references in this page against the specified URL, instead of the URL it submitted to (which will typically be an x.do URI in a Struts application). What are you trying to accomplish with this base setting? Note also that there is a form:base/ tag you can use that generates an HREF of the JSP page itself, so that relative references in JSP pages work the way you think they would (relative to the page itself), even when invoked via a forward. Any tricks? Deping Craig
Re: Action Path Problem when Doc Base used
Deping Chian wrote: Craig, Thanks for your suggestion. But I HAVE to use doc base for all my HTML pages under a certain template. This template has numourous pictures links, company logos, JavaScript libraries, et al, which are already written by someone else, stored in an organized directory structure in another server (i.e. http://java). In this template I inserted a few special tags (e.g. #FAQS/) for my JSP pages to replace with relevant HTMLs. I could setup a String servAddr for the real server address and use a href="%=servAddr%/logoff.do"bean:message key="mainMenu.logoff"//a to replace form:link page="/logoff.do"bean:message key="mainMenu.logoff"//form:link and it now correctly links to http://localhost:8080/logoff.do. But form:link page="%=servAddr%/logoff.do"bean:message key="mainMenu.logoff"//form:link links to http://java/%=servAddr%/logoff.do which is wierd. In other words, it seems that my Tomcat does not translate %=xxx% tag before taglib calls. One thing to note here is that it is not legal JSP syntax to mix a runtime expression and static text in an attribute, like this: form:link page="%= servAddr %/logoff.do" this should be giving you a compile error -- you would replace it with form:link page='%= srvAddr + "/logoff.do" %' instead (note the switch to single quotes around the entire attribute. But, I'm also fixing form:link page="/xxx" so that it works correctly for you, by generating a complete absolute URL instead of a server-relative one. The current logic does not deal correctly with cases where a base tag is present. The fix will be in tonight's nightly build, and you will be able to go back to: form:link page="/logoff.do" Anyway, it's mostly solved for myself. Deping Craig - Original Message - From: "Craig R. McClanahan" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, January 05, 2001 6:42 PM Subject: Re: Action Path Problem when Doc Base used Deping Chian wrote: All my Struts actions work OK until I inserted base href='http://java' in my HTML document. This doc base caused form:link page="/logoff.do"bean:message key="mainMenu.logoff"//form:link to link to http://java/logoff.do and of course Struts action servlet does not know how to handle this. Well, the smart ass answer would be "so don't do that" :-) What the base tag does is tells your browser to resolve relative references in this page against the specified URL, instead of the URL it submitted to (which will typically be an x.do URI in a Struts application). What are you trying to accomplish with this base setting? Note also that there is a form:base/ tag you can use that generates an HREF of the JSP page itself, so that relative references in JSP pages work the way you think they would (relative to the page itself), even when invoked via a forward. Any tricks? Deping Craig
Logging capability in Struts
Hello, I've noticed that there is some logging capability inherent in the Struts framework. However, I wonder if anyone has some experience using some of the logging/trace packages (e.g., log4j or Jlog) with Struts, and what pros/cons there are using the log capability within Struts compared to an external package? Thank you very much, Roger Kjensrud
PLEASE PRETTY PLEASE HELP ME
Hi, I have WLS 5.1 with SP6, Struts 0.5, Xalan-j_1_2_2 and xercs-1_2_3 installed on my machine. I have added the classpaths to weblogic and here is a sample. WebLogic startup settings are presently: CLASSPATH Prefix D:\weblogic\lib\weblogic510sp6boot.jar;D:\Apache\xalan-j_1_2 _2\xalan.jar;D:\Apache\xerces-1_2_3\xerces.jar;D:\Apache\jakarta-struts-0.5\ lib\ struts.jar CLASSPATH D:\weblogic\lib\weblogic510sp6boot.jar;D:\Apache\xalan-j_1_2 _2\xalan.jar;D:\Apache\xerces-1_2_3\xerces.jar;D:\Apache\jakarta-struts-0.5\ lib\ struts.jar;D:\weblogic\jre1_2\lib\tools.jar;D:\weblogic\jre1_2\jre\lib\rt.ja r;D: \weblogic\jre1_2\jre\lib\i18n.jar;D:\weblogic\license;D:\weblogic\classes\bo ot;D :\weblogic\classes;D:\weblogic\lib\weblogicaux.jar;D:\weblogic\eval\cloudsca pe\l ib\cloudscape.jar JAVA_HOME D:\weblogic\jre1_2 WEBLOGIC_LICENSEDIR D:\weblogic\license WEBLOGIC_HOME D:\weblogic system properties: java.security.manager java.security.policy==D:\weblogic\weblogic.policy weblogic.system.home=D:\weblogic java.compiler=symcjit weblogic.class.path=D:\weblogic\lib\weblogic510sp6.jar;d:\We blogic\license;d:\Weblogic\classes;d:\Weblogic\myserver\serverclasses;d:\Web logi c\lib\weblogicaux.jar INITIAL_HEAP64 MB MAX_HEAP64 MB SERVERCLASSPATH D:\weblogic\lib\weblogic510sp6boot.jar;D:\Apache\xalan-j_1_2 _2\xalan.jar;D:\Apache\xerces-1_2_3\xerces.jar;D:\Apache\jakarta-struts-0.5\ lib\ struts.jar;D:\weblogic\jre1_2\jre\lib\rt.jar;D:\weblogic\jre1_2\jre\lib\i18n .jar ;D:\weblogic\classes\boot;D:\weblogic\eval\cloudscape\lib\cloudscape.jar When weblogic starts up it fails with the following error: Fri Jan 05 19:13:52 EST 2001:I WebLogicServer Invoking T3StartupDef StartDatabaseServlet weblogic.servlet.utils.ServletStartup with {servlet=db} Fri Jan 05 19:13:52 EST 2001:I ServletContext-General db: init Fri Jan 05 19:13:53 EST 2001:E ServletContext-General db: Database load exception java.lang.ClassNotFoundException: org/apache/struts/example/User at org.apache.struts.digester.Digester.startElement(Digester.java, Compiled Code) at org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java, Compiled Code) at org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat or.java, Compiled Code) at org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanne r.java, Compiled Code) at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM LDocumentScanner.java, Compiled Code) at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner. java, Compiled Code) at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:948) at javax.xml.parsers.SAXParser.parse(SAXParser.java:345) at javax.xml.parsers.SAXParser.parse(SAXParser.java:143) at org.apache.struts.digester.Digester.parse(Digester.java:748) at org.apache.struts.example.DatabaseServlet.load(DatabaseServlet.java:282) at org.apache.struts.example.DatabaseServlet.init(DatabaseServlet.java:175) at javax.servlet.GenericServlet.init(GenericServlet.java:258) at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java :474) at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.ja va, Compiled Code) at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav a:421) at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav a:342) at weblogic.servlet.utils.ServletStartup.startup(ServletStartup.java:36) at weblogic.t3.srvr.StartupThread.runStartup(StartupThread.java:182) at weblogic.t3.srvr.StartupThread.doWork(StartupThread.java, Compiled Code) at weblogic.t3.srvr.PropertyExecuteThread.run(PropertyExecuteThread.java:62) Fri Jan 05 19:13:53 EST 2001:I WebLogicServer T3StartupDef StartDatabaseServlet weblogic.servlet.utils.ServletStartup reports:servlet: db unable to initialize. javax.servlet.UnavailableException: Cannot load database from 'null' at org.apache.struts.example.DatabaseServlet.init(DatabaseServlet.java:180) at javax.servlet.GenericServlet.init(GenericServlet.java:258) at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java :474) at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.ja va, Compiled Code) at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav a:421) at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav a:342) at weblogic.servlet.utils.ServletStartup.startup(ServletStartup.java:36) at weblogic.t3.srvr.StartupThread.runStartup(StartupThread.java:182) at weblogic.t3.srvr.StartupThread.doWork(StartupThread.java, Compiled Code) at
Re: Logging capability in Struts
FYI, the logging API for Java will only be available in JDK 1.4. --- "Craig R. McClanahan" There has been some discussion of adding a generic Struts logging capability. However, there is currently a Java Community Process JSR to develop a standard logging API for Java (which I understand will likely be somewhat similar to things like LOG4J), so it seems better to wait until that effort is completed. __ Do You Yahoo!? Yahoo! Photos - Share your holiday photos online! http://photos.yahoo.com/
RE: Logging capability in Struts
For things such as logging, it would be a good idea to implement them as an application level service. Application level services are a concept of Larry McCay ([EMAIL PROTECTED]). Basically "Services" is interface based programming for common horizontal services such as logging, object pooling, etc. For logging there could be a homegrown implementation at first, then when logging is standardized we could switch the implementation underneath to use the new mechanism. Also, you could create a Log4j implementation that uses IBM's logging package if you felt like it. We're holding off on a full blown introduction until 1.0 is out, so please bear with us. -Original Message- From: Wong Kok Wai To: [EMAIL PROTECTED] Sent: 1/5/01 8:01 PM Subject: Re: Logging capability in Struts FYI, the logging API for Java will only be available in JDK 1.4. --- "Craig R. McClanahan" There has been some discussion of adding a generic Struts logging capability. However, there is currently a Java Community Process JSR to develop a standard logging API for Java (which I understand will likely be somewhat similar to things like LOG4J), so it seems better to wait until that effort is completed. __ Do You Yahoo!? Yahoo! Photos - Share your holiday photos online! http://photos.yahoo.com/
RE: Logging capability in Struts
Title: RE: Logging capability in Struts This is interesting. You may also be interested in AspectJ (www.aspectj.org). For more context on aspects (which sound similar to what Michael is calling services), please visit http://www.technologyreview.com/articles/jan01/TR10_kiczales.html. -Craig Randall -Original Message- From: Schachter, Michael [mailto:[EMAIL PROTECTED]] Sent: Friday, January 05, 2001 5:22 PM To: '[EMAIL PROTECTED] ' Subject: RE: Logging capability in Struts For things such as logging, it would be a good idea to implement them as an application level service. Application level services are a concept of Larry McCay ([EMAIL PROTECTED]). Basically Services is interface based programming for common horizontal services such as logging, object pooling, etc. For logging there could be a homegrown implementation at first, then when logging is standardized we could switch the implementation underneath to use the new mechanism. Also, you could create a Log4j implementation that uses IBM's logging package if you felt like it. We're holding off on a full blown introduction until 1.0 is out, so please bear with us. -Original Message- From: Wong Kok Wai To: [EMAIL PROTECTED] Sent: 1/5/01 8:01 PM Subject: Re: Logging capability in Struts FYI, the logging API for Java will only be available in JDK 1.4. -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Friday, January 05, 2001 3:08 PM To: [EMAIL PROTECTED] Subject: Re: Logging capability in Struts Roger Kjensrud wrote: Hello, I've noticed that there is some logging capability inherent in the Struts framework. However, I wonder if anyone has some experience using some of the logging/trace packages (e.g., log4j or Jlog) with Struts, and what pros/cons there are using the log capability within Struts compared to an external package? Currently, the only logging Struts does is via ServletContext.log() -- which any servlet can use -- and the log messages go to wherever they are configured for in your servlet container. You could certainly use something like log4j yourself. There has been some discussion of adding a generic Struts logging capability. However, there is currently a Java Community Process JSR to develop a standard logging API for Java (which I understand will likely be somewhat similar to things like LOG4J), so it seems better to wait until that effort is completed. Thank you very much, Roger Kjensrud Craig McClanahan
Locale Message Resources
1. Action class provides getResources() which return MessageResources. Is the MessageResource always the one specified in web.xml ( say ApplicationResources.Properties ) or is it based on the locale set + the one specified in web.xml ( and thus for locale xx it is ApplicationResources_XX.Properties ) 2. In all the *Action.java files in example directory of struts, I see explicit calls being made to getLocale() and getResources() but the values returned arent being used anywhere else in the program. Is it always mandatory for us to explicitly call getLocale and getResources in our action classes? Thanks for any advice Hunt __ Do You Yahoo!? Yahoo! Photos - Share your holiday photos online! http://photos.yahoo.com/
Custom Mapping Class
Thanks for the reply Craig Could some one tell me - When would one want to use a custom ActionMapping class? The example given in bluestone.com doesnt convince me. Thanks Hunt --- "Craig R. McClanahan" [EMAIL PROTECTED] wrote: John Hunt wrote: 1. Action class provides getResources() which return MessageResources. Is the MessageResource always the one specified in web.xml ( say ApplicationResources.Properties ) or is it based on the locale set + the one specified in web.xml ( and thus for locale xx it is ApplicationResources_XX.Properties ) Yah, this can be a little confusing. In web.xml, you configure the location of your message resources (using the default MessageResources implementation, this is a name that looks like a Java class name -- the example app uses "org.apache.struts.example.ApplicationResources"). Although there is only one MessageResources instance, it is initialized from *all* of the properties files that have the base name you've identified. The first time you ask for a message with a new locale, the corresponding properties file is loaded if necessary, transparent to you. 2. In all the *Action.java files in example directory of struts, I see explicit calls being made to getLocale() and getResources() but the values returned arent being used anywhere else in the program. Is it always mandatory for us to explicitly call getLocale and getResources in our action classes? No, you can chalk that up to a little bit of over-aggressive cut and paste :-). You need only call these getters if you need to use the results. Thanks for any advice Hunt Craig McClanahan __ Do You Yahoo!? Yahoo! Photos - Share your holiday photos online! http://photos.yahoo.com/
Re: PLEASE PRETTY PLEASE HELP ME
There's been a lot of questions about Weblogic. I didn't follow it all, but you could try a search at http://www.mail-archive.com/struts-user%40jakarta.apache.org/ You will also get better answers to questions like these on the USER list, where I know there are a lot of WebLogic people. This list is meant for people writing new versions of Struts, rather than about using an existing version. *** REPLY SEPARATOR *** On 1/5/2001 at 7:32 PM [EMAIL PROTECTED] wrote: Hi, I have WLS 5.1 with SP6, Struts 0.5, Xalan-j_1_2_2 and xercs-1_2_3 installed on my machine. I have added the classpaths to weblogic and here is a sample. WebLogic startup settings are presently: CLASSPATH Prefix D:\weblogic\lib\weblogic510sp6boot.jar;D:\Apache\xalan-j_1_2 _2\xalan.jar;D:\Apache\xerces-1_2_3\xerces.jar;D:\Apache\jakarta-struts- 0.5\ lib\ struts.jar CLASSPATH D:\weblogic\lib\weblogic510sp6boot.jar;D:\Apache\xalan-j_1_2 _2\xalan.jar;D:\Apache\xerces-1_2_3\xerces.jar;D:\Apache\jakarta-struts- 0.5\ lib\ struts.jar;D:\weblogic\jre1_2\lib\tools.jar;D:\weblogic\jre1_2\jre\lib\r t.ja r;D: \weblogic\jre1_2\jre\lib\i18n.jar;D:\weblogic\license;D:\weblogic\classe s\bo ot;D :\weblogic\classes;D:\weblogic\lib\weblogicaux.jar;D:\weblogic\eval\clou dsca pe\l ib\cloudscape.jar JAVA_HOME D:\weblogic\jre1_2 WEBLOGIC_LICENSEDIR D:\weblogic\license WEBLOGIC_HOME D:\weblogic system properties: java.security.manager java.security.policy==D:\weblogic\weblogic.policy weblogic.system.home=D:\weblogic java.compiler=symcjit weblogic.class.path=D:\weblogic\lib\weblogic510sp6.jar;d:\We blogic\license;d:\Weblogic\classes;d:\Weblogic\myserver\serverclasses;d: \Web logi c\lib\weblogicaux.jar INITIAL_HEAP64 MB MAX_HEAP64 MB SERVERCLASSPATH D:\weblogic\lib\weblogic510sp6boot.jar;D:\Apache\xalan-j_1_2 _2\xalan.jar;D:\Apache\xerces-1_2_3\xerces.jar;D:\Apache\jakarta-struts- 0.5\ lib\ struts.jar;D:\weblogic\jre1_2\jre\lib\rt.jar;D:\weblogic\jre1_2\jre\lib\ i18n .jar ;D:\weblogic\classes\boot;D:\weblogic\eval\cloudscape\lib\cloudscape.jar When weblogic starts up it fails with the following error: Fri Jan 05 19:13:52 EST 2001:I WebLogicServer Invoking T3StartupDef StartDatabaseServlet weblogic.servlet.utils.ServletStartup with {servlet=db} Fri Jan 05 19:13:52 EST 2001:I ServletContext-General db: init Fri Jan 05 19:13:53 EST 2001:E ServletContext-General db: Database load exception java.lang.ClassNotFoundException: org/apache/struts/example/User at org.apache.struts.digester.Digester.startElement(Digester.java, Compiled Code) at org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java, Compiled Code) at org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLVal idat or.java, Compiled Code) at org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentSc anne r.java, Compiled Code) at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatc h(XM LDocumentScanner.java, Compiled Code) at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScan ner. java, Compiled Code) at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:948) at javax.xml.parsers.SAXParser.parse(SAXParser.java:345) at javax.xml.parsers.SAXParser.parse(SAXParser.java:143) at org.apache.struts.digester.Digester.parse(Digester.java:748) at org.apache.struts.example.DatabaseServlet.load(DatabaseServlet.java:282) at org.apache.struts.example.DatabaseServlet.init(DatabaseServlet.java:175) at javax.servlet.GenericServlet.init(GenericServlet.java:258) at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl. java :474) at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImp l.ja va, Compiled Code) at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl .jav a:421) at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl .jav a:342) at weblogic.servlet.utils.ServletStartup.startup(ServletStartup.java:36) at weblogic.t3.srvr.StartupThread.runStartup(StartupThread.java:182) at weblogic.t3.srvr.StartupThread.doWork(StartupThread.java, Compiled Code) at weblogic.t3.srvr.PropertyExecuteThread.run(PropertyExecuteThread.java:62 ) Fri Jan 05 19:13:53 EST 2001:I WebLogicServer T3StartupDef StartDatabaseServlet weblogic.servlet.utils.ServletStartup reports:servlet: db unable to initialize. javax.servlet.UnavailableException: Cannot load database from 'null' at org.apache.struts.example.DatabaseServlet.init(DatabaseServlet.java:180) at javax.servlet.GenericServlet.init(GenericServlet.java:258) at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl. java :474) at