Re: Digester Question
On Mon, 4 Mar 2002, Craig Tataryn wrote: I realize that the digester is now part of commons, but I figure there is probably a lot of expertise here since it grew up in Struts. I was wondering if someone could help me figure out the easiest way to do this: I have an xml document, that holds form data, I would like to use the digester to populate my objects automatically. A form file might look like this: forms form type=shopping-cart /form form type=calculator ... /form ... /forms Let's assume there are many forms... I was wondering, without having to load all forms into objects and then picking the one I want to use, I would rather the digester only instantiate and populate an object for lets say, the form node who's type attribute is calculator. What's the easiest way to do this? I don't think the digester can pattern match on attribute values the way XPath does, so is there a programming technique I can use to filter further? Hi Craig. Since, AFAIK, the digester blindly instantiates all of the implied objects in your database file, I think that you'll need to parse the database file independently. You might try parsing the database file using JDOM, extracting the elements that you want and passing that snippet to the digester. I think that utilizing JDOM, you'll get working code much faster than you would with raw SAX parsing. I have used JDOM but I haven't tried utilizing it with the digester - just an idea. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: html:link problem
On Thu, 5 Jul 2001, Greg Reddin wrote: I need to use one of forward, href or page. So now my problems are: Try setting up the href attribute to read href=javascript:performAction(...) and see if that works. Good idea. Unfortunately, it didn't work. I tried: html:link href=javascript:performAction(form, 'simpleQuery.do') paramId=offset paramName=resultNavigator paramProperty=startIndex but got: Exception Report: javax.servlet.ServletException: javascript:performAction(form, 'simpleQuery.do')?offset=0 at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:481) at _0002fsimpleQuery_0002ejspsimpleQuery_jsp_6._jspService(_0002fsimpleQuery_0002ejspsimpleQuery_jsp_6.java:1844) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) ... Root Cause: java.lang.IllegalArgumentException: javascript:performAction(form, 'simpleQuery.do')?offset=0 at org.apache.catalina.connector.HttpResponseBase.toAbsolute(HttpResponseBase.java:639) at org.apache.catalina.connector.HttpResponseBase.encodeURL(HttpResponseBase.java:918) at org.apache.struts.util.RequestUtils.computeURL(RequestUtils.java:418) at org.apache.struts.taglib.html.LinkTag.doStartTag(LinkTag.java:338) at _0002fsimpleQuery_0002ejspsimpleQuery_jsp_6._jspService(_0002fsimpleQuery_0002ejspsimpleQuery_jsp_6.java:1044) ... I also tried: html:link href=javascript:performAction(form, 'simpleQuery.do?offset=%= 10*i %') but got an IllegalArgumentException.
html:link problem
Hello. I'm trying to use html:link to submit the contents of a form. The problem is that when I submit the form using html:link, the ActionForm bean is not populated. My form looks like: html:form action=simpleQuery.do ... html:link forward=simpleQuery paramId=offset paramName=resultNavigator paramProperty=startIndex {Stuff here} /html:link ... /html:form In struts-config.xml, I've defined a global forward mapping from simpleQuery to /simpleQuery.do . The parameter offset passes as a request parameter to the Action class okay. The only difference in the processing within Struts that I see is that, for a form submission with the Submit button, Struts sees a POST whereas for the html:link it sees a GET operation. For example, output when using html:submit: 2001-07-03 16:30:07 action: Processing a POST for /simpleQuery 2001-07-03 16:30:07 action: Looking for ActionForm bean under attribute 'simpleQueryForm' 2001-07-03 16:30:07 action: Creating new ActionForm instance of class 'edu.ucar.comet.struts.SimpleQueryForm' 2001-07-03 16:30:07 action: Storing instance under attribute 'simpleQueryForm' in scope 'request' 2001-07-03 16:30:07 action: Populating bean properties from this request 2001-07-03 16:30:07 action: Validating input form properties 2001-07-03 16:30:07 action: No errors detected, accepting input 2001-07-03 16:30:07 action: Looking for Action instance for class edu.ucar.comet.struts.SimpleQueryAction output when using html:link: 2001-07-03 16:30:24 action: Processing a GET for /simpleQuery 2001-07-03 16:30:24 action: Looking for ActionForm bean under attribute 'simpleQueryForm' 2001-07-03 16:30:24 action: Creating new ActionForm instance of class 'edu.ucar.comet.struts.SimpleQueryForm' 2001-07-03 16:30:24 action: Storing instance under attribute 'simpleQueryForm' in scope 'request' 2001-07-03 16:30:24 action: Populating bean properties from this request 2001-07-03 16:30:24 action: Validating input form properties 2001-07-03 16:30:24 action: No errors detected, accepting input 2001-07-03 16:30:24 action: Looking for Action instance for class edu.ucar.comet.struts.SimpleQueryAction
Re: html:link problem
Thanks for your reply Matt. I tried invoking a Javascript function to perform the form submission, e.g.: html:link onclick=performAction(form, 'simpleQuery.do') forward=simpleQuery paramId=offset paramName=resultNavigator paramProperty=startIndex {Stuff here} /html:link but the forward attribute overrides the onclick. If I leave out the forward attribute, the JSP doesn't compile complaining that I need to use one of forward, href or page. So now my problems are: 1) How can I invoke the Javascript function (and ignore the hyperlink attribute) 2) How do I pass the request parameter (can I still use paramId, etc.) Thanks in advance. On Tue, 3 Jul 2001, Matt Raible wrote: You cannot use a link to submit a form, unless you call a javascript function from the link. The link will only submit its parameters to the form bean. Hope this helps, Matt --- Steve A Drake [EMAIL PROTECTED] wrote: Hello. I'm trying to use html:link to submit the contents of a form. The problem is that when I submit the form using html:link, the ActionForm bean is not populated. My form looks like: html:form action=simpleQuery.do ... html:link forward=simpleQuery paramId=offset paramName=resultNavigator paramProperty=startIndex {Stuff here} /html:link ... /html:form In struts-config.xml, I've defined a global forward mapping from simpleQuery to /simpleQuery.do . The parameter offset passes as a request parameter to the Action class okay. The only difference in the processing within Struts that I see is that, for a form submission with the Submit button, Struts sees a POST whereas for the html:link it sees a GET operation. For example, output when using html:submit: 2001-07-03 16:30:07 action: Processing a POST for /simpleQuery 2001-07-03 16:30:07 action: Looking for ActionForm bean under attribute 'simpleQueryForm' 2001-07-03 16:30:07 action: Creating new ActionForm instance of class 'edu.ucar.comet.struts.SimpleQueryForm' 2001-07-03 16:30:07 action: Storing instance under attribute 'simpleQueryForm' in scope 'request' 2001-07-03 16:30:07 action: Populating bean properties from this request 2001-07-03 16:30:07 action: Validating input form properties 2001-07-03 16:30:07 action: No errors detected, accepting input 2001-07-03 16:30:07 action: Looking for Action instance for class edu.ucar.comet.struts.SimpleQueryAction output when using html:link: 2001-07-03 16:30:24 action: Processing a GET for /simpleQuery 2001-07-03 16:30:24 action: Looking for ActionForm bean under attribute 'simpleQueryForm' 2001-07-03 16:30:24 action: Creating new ActionForm instance of class 'edu.ucar.comet.struts.SimpleQueryForm' 2001-07-03 16:30:24 action: Storing instance under attribute 'simpleQueryForm' in scope 'request' 2001-07-03 16:30:24 action: Populating bean properties from this request 2001-07-03 16:30:24 action: Validating input form properties 2001-07-03 16:30:24 action: No errors detected, accepting input 2001-07-03 16:30:24 action: Looking for Action instance for class edu.ucar.comet.struts.SimpleQueryAction __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ --- Steve Drake[EMAIL PROTECTED] UCAR / COMET (303) 497 - 8496 PO Box 3000 Boulder, CO 80307-3000
Re: Multibox confusion after reading Struts mail-archive
On Thu, 21 Jun 2001, Becky Moyer wrote: Steve, Thanks so much for your reply, it gave me some more leads to follow. I have been playing with this for the last 2 days...I have tried to change my webapp to be similar to yours. That could get ugly. =:] I made my form have 2 string arrays, but when I try to iterate over my form as you have done in the example you gave, I either had to iterate over one string array or the other, and when I tried to specify the property in the multibox tag, it couldn't find the getter...I am assuming that, in step with the example you gave, Struts is trying to do a advancedQueryForm.getFindAssets().getSelectedAssets() for the multibox, when I think you are saying it should be doing an advancedQueryForm.getSelectedAssets(). I am still plodding along, but haven't made much progress. Is there something I'm missing? Thanks, Becky It sounds like you are getting close to what I'm using. I'm only iterating over the String[] that contains all the possible values. Values in the other String[] that match the array you are iterating over will cause the checkboxes to be set to checked (but you don't need to iterate over this second String[]). Also make sure the array you are iterating over always contains all of the possible attributes, either by saving it in session scope or repopulating it each time in request scope (i.e., don't set it to null in reset()). In the ActionForm, I have: private String[] findAssets = null; private String[] selectedAssets = null; /** * Get */ public String[] getFindAssets() { return (this.findAssets); } /** * Set * * @param */ public void setFindAssets(String[] findAssets) { this.findAssets = findAssets; } /** * Get */ public String[] getSelectedAssets() { return (this.selectedAssets); } /** * Set * * @param */ public void setSelectedAssets(String[] selectedAssets) { this.selectedAssets = selectedAssets; }
Re: Multibox confusion after reading Struts mail-archive
On Tue, 19 Jun 2001, Becky Moyer wrote: Hi all... I've read all I can find in the archives about the html:multibox tag, and I have gotten farther, but I still would like to ask for some help. In my jsp, I have the following: logic:iterate id=item1 name=entryData html:multibox name=item1 property=subscriptionStatus value=true/ /logic:iterate Where entryData is an ArrayList of class EntryInfo, that has a getSubscriptionStatus() which returns a boolean. This displays properly, and i see the appropriate boxes checked. The associated Form bean has a boolean[] subscriptionStatus field with the associated getter and setter methods. When I try to evaluate the form in my ActionClass, the result of form.getSubscriptionStatus() is null. I have also implemented the reset() method in my form where I iterate through the subscriptionStatus array in the Form and set all values to null. My questions are... 1) I thought the property Attribute in the multibox tag refered to the property in the form that would be submitted. I may very well be mistaken, but it seems from my experiments, the property attrubute specifies which value will be displayed. How does this work? If it represents which value will be displayed, how do you get the information into your form? 2) As in the struts-exercise-taglib webapp, it appears that when you use a multibox, you use an array of foo as the parameter that stores the result in the form. Is this right? My confusion about this seems to be one of my possible downfalls with getting information into my form. Thanks so much for reading my rambles, and any thoughts or clarifications would be excitedly welcomed. -Becky- [EMAIL PROTECTED] Hello Becky. I flailed around with multibox myself before I found something that worked. In the example below, I implemented two String[] arrays in the ActionForm, findAssets and selectedAssets. findAssets maintains all of the possible values and selectedAssets maintains the currently selected values. Iterate over all the possible values to print the checkbox name and use the property setting of the selected values to set the checkboxes. logic:iterate name=advancedQueryForm property=findAssets id=element html:multibox property=selectedAssets bean:write name=element / /html:multibox bean:write name=element / br / /logic:iterate Hope this helps.
i18n + html:link
Hello. I am trying to implement internationalized rollover buttons using html:link. To do this, I'm trying to use quotes three levels deep and I guess that's illegal in Javascript. For example, for onmouseover, if I try to extract the source name from the resource file, I try: onmouseover=changeImage('bean:message key=header.simpleQueryImageSourceR/') then I get a servlet exception: A Servlet Exception Has Occurred org.apache.jasper.compiler.ParseException: /usr/apps/tomcat/jakarta-tomcat-4.0-b 1/webapps/moria/test.jsp(55,84) Attribute header.simpleQueryImageSourceR has no value at org.apache.jasper.compiler.JspReader.parseAttributeValue(JspReader.java:565) at org.apache.jasper.compiler.JspReader.parseTagAttributes(JspReader.java:683) at org.apache.jasper.compiler.Parser$Tag.accept(Parser.java:826) ... If I hardwire the source name that I'm trying to extract, it works. For example: onmouseover=changeImage('simpq_en_r') I'm using Struts 1.0-b3. Ideas are appreciated. Thanks in advance.
Re: i18n + html:link
On Wed, 13 Jun 2001, Oleg V Alexeev wrote: You can create javascript functions to implement logic and refer to it from in onmouseover event. In javascript you can insert scriptlet code or bean:message tags. Thanks Oleg and Dallas for your responses. Embedding bean:message tags in a javascript function worked.
RE: Any Hashmap examples used in jsp page?
On Mon, 4 Jun 2001, Shamdasani Nimmi-ANS004 wrote: Steve, This is how I used a HashMap in a jsp: logic:iterate id=item name=user_list property=userList TR TDbean:write name=item property=key//TD TDbean:write name=item property=value//TD /TR /logic:iterate getUserList() method in my user_list bean returns a HashMap. Hope this helps. -Nimmi Hi Nimmi. Your example would work fine if I didn't care about the order in which the key/value pairs are displayed. Unfortunately, I need to display them in a particular order (given by a String[] of keys).
RE: Any Hashmap examples used in jsp page?
On Mon, 4 Jun 2001, Deadman, Hal wrote: I don't think what you are trying to do should be done in the JSP by a struts/custom tag. Maybe it's a dumb idea, but that's never stopped me before. =:] Why not copy the value objects in the HashMap to an array based on the order of the keys in your String array? Then pass the array to the JSP instead of the HashMap. If you need the keys and they aren't attributes of the value objects then you can pass the String array of keys to the JSP too. I used an ArrayList of String[]s and that worked fine. Thanks.
RE: Any Hashmap examples used in jsp page?
Hi Jon. I'm having a similar problem as Dudley with a HashMap. I tried playing around with your example but couldn't get it to work within the context of what I'm doing. Perhaps another example would help. For example, I have a scriptlet that looks something like: fee.fie.fo.sql.ResultSetBean rsb = (fee.fie.fo.sql.ResultSetBean) request.getAttribute(resultBean); java.util.HashMap hm = rsb.getProperties(); String foobar = (String) hm.get(foobar); out.println(foobar = + foobar); So, the ResultSetBean contains a HashMap as a property. I get a reference to the HashMap and then can extract a value with a key as input. Any ideas on the syntax of doing this with bean tags? TIA. On Fri, 1 Jun 2001, Jon.Ridgway wrote: Hi Dudley, See code sample below. The type in the iterate tag must be as shown, you will then need to use a bean define to put your 'value' into the page context and cast it to whatever type you have placed in your HashMap value. Hope this helps, Jon. logic:iterate id=list name=gallery property=artifacts type=java.util.Map.Entry bean:define id=artifact name=list property=value type=net.itwa.model.artifact.IArtifact/ bean:write name=artifact property=description/ /logic:iterate -Original Message- From: Dudley Butt@i-Commerce [mailto:[EMAIL PROTECTED]] Sent: 01 June 2001 10:34 To: [EMAIL PROTECTED] Subject: Any Hashmap examples used in jsp page? Hi all, Could anyone please point me to where i can find some examples using hashmaps in a jsp with struts... Instead of using a whole bunch of logic equal tags all the time, i need a way to evaluate a collection, looking for a specific key value, then show or hide the relevant input boxes on my jsp.. any help...please!!!??? --- Steve Drake[EMAIL PROTECTED] UCAR / COMET (303) 497 - 8496 PO Box 3000 Boulder, CO 80307-3000
extract key/value from HashMap
Hello. I have a bean (referred to as resultBean) that contains a HashMap (called properties) and would like to extract key/value pairs from this HashMap. Presently, I'm iterating through the HashMap with: logic:iterate id=element name=resultBean property=properties bean:write name=element property=key/ bean:write name=element property=value/ br / /logic:iterate The problem is that I'd like to be able to extract and display the values in an order other than the order the key/value pairs are returned through the iteration mechanism. (For example, supply a key explicitly and extract it's value.) Any ideas on how to accomplish this using tags? Thanks in advance.
multibox
Hello. I'm trying to use html:multibox with one String[] that contains Strings for all of the checkboxes to display and another String[] that contains the currently selected checkboxes. With the following code, I can display the checkboxes but don't understand how to control which box or boxes are checked (with the other String[]). For example, logic:iterate name=myForm property=findAssets id=element html:multibox property=findAssets bean:write name=element / /html:multibox bean:write name=element / br / /logic:iterate generates a set of multiboxes that have the boxes checked. How would I rewrite this to generate the multiboxes that use another String[] to indicate which boxes are checked? Or is there a better way? Thanks.
RE: Javascript and struts
On Thu, 5 Apr 2001, Dorai, Harish (c) wrote: It seems the onclick event overrides the submit action and hence your form is not getting submitted. Instead of using form:submit use the Button tag and in the onclick function put this code. The html:submit tag creates an input type of submit with a default name of submit. The problem is that this default name conflicts with the Javascript function form.submit(). I entered a more lengthy note about this at http://marc.theaimsgroup.com/?l=struts-userm=98460389910114w=2 There are a number of ways to hack around this problem including: 1) use an html:button instead 2) set the property for the html:submit tag to something other than submit. I consider the behavior of html:submit to be a functional bug because the default attributes don't work when you use the form.submit() Javascript function. I would prefer that the html:submit tag create an input type with a name other than submit to prevent this naming conflict.
Re: Packaging Question - Include Source in Binary Distributions?
On Mon, 23 Apr 2001, Dzenan Ridjanovic wrote: OK to just point at the download URL for the source distribution if you want it! +1
Re: radio set example
On Thu, 12 Apr 2001, Cox, Tom wrote: Hello: I'm looking for an example of the html:radio ... tag. I need to present several radio options, and have one option be preselected based on the value in my ActionForm bean. AFAIK, and someone set me straight if this is wrong, there is no html:radio attribute to dynamically set the radio button value. I'm using a hack like: % String yeah = "true"; String nay = "false"; % html:radio property="myBoolean" value="%= (myForm.getMyBoolean() ? yeah : nay)%" bean:message key="query.myBoolean"/ /html:radio From the mail list, it sounds like some people are using String for fields like radio buttons that you might otherwise define as boolean. That would save the ternary operation but seems even uglier to me. =:| To define another radio button in the same set, use that same property but give it an independent value and use a different message key. Hope this helps.
config String[] with Digestor
I'd like to initialize a String[] contained in an object with the Digestor (i.e. in a database.xml file). Can I do that? If so, what's the syntax? Thanks.
html:submit
I'm having a problem with the html:submit tag. The scenario is that I have a number of select menus, each of which invokes form.submit() on the onchange event, i.e.: html:select property="databaseTables" onchange="form.submit()" The problem is that the html:submit tag creates a Submit input type with the name "submit". I think this name is conflicting with the form.submit() Javascript function. The html:submit tag : html:submit bean:message key="button.submit"/ /html:submit creates an input type that looks like: input type="submit" name="submit" value="Start Search" By hardwiring the input type (not using the html:submit tag) with a "name" attribute other than "submit", the select menus properly invoke form.submit(). Otherwise, the select menus generate the Javascript error: Javascript Error: form.submit is not a function Any advice is appreciated.
RE: html:submit
On Wed, 14 Mar 2001, Kyle Robinson wrote: In the onchange event of your select I would make it look like onchange="javascript:submit();" Thanks for the idea, but I tried that and still get the Javascript error.
RE: Strut Books
On Mon, 12 Mar 2001, Rudy Bonefas wrote: Hey, Maybe someone at Jakarta could look into setting up a news group so that my inbox is constantly spammed with useless shit like the following. Apparently, you are not aware that struts-user is well-behaved and doesn't flame.
Re: Database pooling code
On Wed, 7 Mar 2001, Jim Richards wrote: Has anyone got the database pooling code/DataSource to work or specifically had it fail? I've been having problems (documented previously) and I've read about a few others who can't seem to get the pooling to work as well, and I want to get an idea of specifically where the problem might lie in order to fix it. I'm using the database connection pool with Informix Dynamic Server v7.2 and it appears to be working well. I have noticed that if my network connection goes down (I pull the plug on the network for a while), I need to restart Tomcat to reinitialize the connection pool. If I only momentarily pull the plug, the subsequent query takes longer to run, but does so successfully. I admit, I have not looked into the details of all this. But if there is a way to automate detection of an expired connection and tossing it, or reinitializing the connection pool (if all the connections are bad), I'd certainly be interested in having that capability either incorporated into Struts or available as a patch. Thanks.
Re: paging for web application
On Wed, 31 Jan 2001, Peter Alfors wrote: check out the pager taglib: http://jsptags.com/tags/navigation/pager/ Very handy! For anyone else looking at this for paging long-winded result sets, and using Tomcat 4.0-b1, I needed to edit the demo "pager-demo.jsp" and change: pg:pager maxIndexPages="%= 20 %" to: pg:pager maxIndexPages="20" This fixes a hack put in to convert "20" to an int as delineated in the pager troubleshooting section.
Re: paging for web application
On Wed, 31 Jan 2001, Peter Alfors wrote: check out the pager taglib: http://jsptags.com/tags/navigation/pager/ Actually, I can run the example that comes with the distribution but am having some problems using this pager taglib in Struts. The links created by the pager aren't working. The example I'm working on has a JSP with an embedded form that, upon submission, invokes a database query and reads back the results stored in request scope beans (to the same JSP). The pager creates the correct number of links to result pages. For example, one link created is: http://localhost/project/simpleQuery.jsp?pager.offset=1 But when I click on this link I only get my simple query form and the pager output of: Result Pages [Prev] 1 but no other results. I've also tried typing in the URL: http://localhost/project/simpleQuery.do?pager.offset=1 with the same result (or lack there-of). Ideas? Any help is appreciated! Sorry if this is off-topic for Struts.
Re: paging for web application
On Mon, 12 Feb 2001, Steve A Drake wrote: On Wed, 31 Jan 2001, Peter Alfors wrote: check out the pager taglib: http://jsptags.com/tags/navigation/pager/ Actually, I can run the example that comes with the distribution but am having some problems using this pager taglib in Struts. The links created by the pager aren't working. Well, I did get this working but with a couple of major caveats. 1) In order to define a given pg:index, I had to use scriptlets for all the code between the start and end tag. I assume this is because - from what someone enlightened me earlier with - you can't nest tags. I hope I'm wrong about this because it significantly clutters up the JSP and renders all the bean tags unusable. =:| 2) I needed to locate the hypertext index at the bottom of the document because the index dimensions are determined as the results are iterated. I assume this could be fixed by buffering the output to a StringBuffer or somesuch but havn't tried that yet. If anyone has some usage suggestions for this pager taglib, I'd appreciate your input.
MessageFormat question
Hello. I'm trying to use a MessageFormat tag with a dynamically defined argument in a JSP but can't seem to get the syntax right. In my MessageResource file I have the string: header.simpleResults=There were {0} responses and in my JSP file I have: bean:message key="heading.simpleResult" arg0='bean:write name="resultSetInfo" property="referenceNum"/'/ By itself, bean:write name="resultSetInfo" property="referenceNum"/ returns a non-null value. But I can't get the syntax right in this context and so the arg0 expression is returned as a String, as written. BTW, I'm trying to avoid using a scriptlet to define "arg0" and use the Struts tags instead. How can you do that? Thanks for any insights.
Re: configuring database connection pool
As a follow-up to the problem I was having with the setReadOnly() method for the Connection object (using Informix), I downloaded the latest/greatest JDBC driver that I could find (SQLJ 2.20.JC1 from www.informix.com/evaluate) and found the same problem. From the release notes (file: jdbcrel.txt) it's clear that Informix (Dynamic Server 7.24.UC7-1) doesn't support read-only mode: -79745 Read only mode not supported Informix does not support read-only mode. That answers that question. The good news is that with the following patch to org/apache/struts/util/GenericConnection.java, I have been able to utilize the Datasource configuration in struts-config.xml to load the Informix JDBC driver and then generate a non-null ResultSet: $ diff GenericConnection.java.orig GenericConnection.java 127c127,131 this.conn.setReadOnly(this.readOnly); --- try { this.conn.setReadOnly(this.readOnly); } catch (SQLException e) { ; // Informix throws a "Read only mode not supported" exception } This patch should not negatively impact other database configurations so I'm hoping it will be incorporated into Struts. I noticed a patch in there for PostgreSQL also, so this looks like the appropriate place to patch. For future reference, in struts-config, the following datasource configuration worked: data-source autoCommit="false" description="Informix Data Source Configuration" driverClass="com.informix.jdbc.IfxDriver" maxCount="4" minCount="2" password="{password}" url="jdbc:informix-sqli://{InformixServer}:1520/{Database}:informixserver= {InformixServer}" user="{user}" / where {user}, {password}, {InformixServer}, and {Database} were explicitly defined (i.e. I just put in placeholders, here).
2 Qs
Any struts gurus going to the O'Reilly Conference on Enterprise Java (March 26-29)? I didn't see Struts on the schedule but that's not to say someone couldn't lead an impromptu evening session. I've got this Struts connection pool going but don't see how to snoop info regarding it's state. For example, does anyone know how to get the number of connections currently checked out from a connection pool? I looked at the classes in the JDBC 2.0 Optional Package but didn't see anything other than possibly implementing a connection event listener =:| . Code examples, anyone? TIA.
configuring database connection pool
Hello. I'm trying to configure Struts to instantiate a database connection pool using the ifxjdbc.jar driver for the Informix Dynamic Server (7.2). So far, I'm getting exceptions at startup. I also get an exception when I try to obtain a DB connection. Any help would be appreciated! Note that I've verified that the Informix driver works fine in a sample servlet run outside of Struts. Also, I get the same error regardless of the value for "readOnly", even if it's not defined. My struts-config.xml file looks like: data-sources data-source autoCommit="false" readOnly="true" description="Informix Data Source Configuration" driverClass="com.informix.jdbc.IfxDriver" maxCount="4" minCount="2" password="thatestufa" url="jdbc:informix-sqli://yowza:1520/db:informixserver=yowza" user="thisestufa" / /data-sources And in the tomcat (4.0 beta) log file I'm getting: 2001-01-25 18:14:23 action: Loading application resources from resource org.apache.struts.example.ApplicationResources 2001-01-25 18:14:23 action: Initializing configuration from resource path /WEB-INF/struts-config.xml 2001-01-25 18:14:23 action: Initializing application data source org.apache.struts.action.DATA_SOURCE 2001-01-25 18:14:24 action: Exception initializing application data source org.apache.struts.action.DATA_SOURCE java.sql.SQLException at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:308) at com.informix.jdbc.IfxSqliConnect.setReadOnly(IfxSqliConnect.java:1484) at org.apache.struts.util.GenericConnection.init(GenericConnection.java:127) at org.apache.struts.util.GenericDataSource.createConnection(GenericDataSource.java:623) at org.apache.struts.util.GenericDataSource.open(GenericDataSource.java:561) at org.apache.struts.action.ActionServlet.initDataSources(ActionServlet.java:998) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:444) at javax.servlet.GenericServlet.init(GenericServlet.java:258) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:755) at org.apache.catalina.core.StandardContext.start(StandardContext.java:2979) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:816) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:334) at org.apache.catalina.core.StandardHost.deploy(StandardHost.java:545) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:294) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:383) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:226) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:155) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1172) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1160) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:217) at org.apache.catalina.core.StandardService.start(StandardService.java:353) at org.apache.catalina.core.StandardServer.start(StandardServer.java:454) at org.apache.catalina.startup.Catalina.start(Catalina.java:654) at org.apache.catalina.startup.Catalina.execute(Catalina.java:595) at org.apache.catalina.startup.Catalina.process(Catalina.java:176) at java.lang.reflect.Method.invoke(Native Method) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:157)
Re: configuring database connection pool
On Thu, 25 Jan 2001, Craig R. McClanahan wrote: It looks like the Informix JDBC driver is throwing an exception when you call setReadOnly(true) on one of its connections. Could you try that in a standalone program and see what happens, and also what happens if you call setReadOnly(false)? Okay, thanks for the advice. I tried running this sample code with the "user" as myself (who owns the tables), another user, and as user "informix", who should have global read/write privileges. As any of these users I can get a non-null result set from a select statement. I tried the following code snippet: try { boolean yup = true; conn.setReadOnly(yup); } catch (SQLException e) { System.out.println("Bummer, dude: got an exception "); e.printStackTrace(System.out); } Regardless of the value for "yup", I got this exception: Bummer, dude: got an exception java.sql.SQLException at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:308) at com.informix.jdbc.IfxSqliConnect.setReadOnly(IfxSqliConnect.java:1484) at edu.ucar.comet.sql.SqlManager$Test.main(SqlManager.java:245) So, it does not look like a Struts problem. Looking at the database table privileges, I have: UserSelect Update Insert Delete Index Alter public AllAllYes Yes Yes No Looks okay to me. I think I'll search in ernest for some API docs for this driver tomorrow. Maybe that'll shed some light. Any other ideas would also be appreciated.
Re: nightly build
On Mon, 22 Jan 2001, Steven D. Wilkinson wrote: Here is what the installation doc says: "XML Parser - Struts requires the presence of an XML parser that is compatible with the Java API for XML Parsing (JAXP) specification, 1.0 or later. You can download and install the JAXP reference implementation, which is required for building the Struts source distribution. In Struts-based web applications, you may replace the reference implementation classes with any other JAXP compliant parser, such as Xerces. See detailed instructions related to the parser in the instructions for building and installing Struts, below." Yeah, I saw this in the README file that came with the distribution. "Xalan XSLT Processor - If you are building Struts from the source distribution, you must download and install version 1_2_D01 (or later) of the Xalan XSLT processor (which also includes the Xerces XML parser). This processor is used to convert the Struts documentation from its internal XML-based format into the HTML that is presented in the Struts documentation application. " This was not in the README file. Here's the URL http://jakarta.apache.org/struts/installation.html#Prerequisites Next time, I'll check here first. Also, I am just starting a project that I plan to use Struts 1.x. I plan on developing on Tomcat and eventually deploying on Tomcat/Apache. Does this sound reasonable? Should I plan on developing and deploying on Tomcat 3.2.1 or 4.x? I have mixed thoughts about deploying on a servlet engine (4.x) that's implementing on new (2.3) servlet API. Thanks in advance for your advice. I'm running on milestone 5 release of Tomcat4.0. I have been for a while. No problems. I won't upgrade until official release comes out since I'm having no problems. It works great. Don't let the fact that it implements the 2.3 API stop you. It still supports 2.2 stuff. Not like the 2.1 to 2.2 change. BTW, Tomcat4.0 is kewl! I really like the new logging. It's also very stable. Sounds like good advice. Thanks.
nightly build
Hello. I downloaded last night's build and compiled it. I was able to compile it with xalan/xerces (that I coopted from Cocoon 1.8) but not with jaxp.jar/parser.jar (that I coopted from Tomcat 3.2.1). From the stacktrace (see below), it looks like an Ant (1.2) "import" problem, but it's a Struts problem too if you can't compile it! I also tried the jaxp.jar/parser.jar combination that came with Ant but had the same negative result. (BTW, I don't have multiple parsers in my classpath.) Also, I am just starting a project that I plan to use Struts 1.x. I plan on developing on Tomcat and eventually deploying on Tomcat/Apache. Does this sound reasonable? Should I plan on developing and deploying on Tomcat 3.2.1 or 4.x? I have mixed thoughts about deploying on a servlet engine (4.x) that's implementing on new (2.3) servlet API. Thanks in advance for your advice. BUILD FAILED /usr/apps/struts/jakarta-struts/build.xml:125: java.lang.NoClassDefFoundError: o rg/apache/xalan/xslt/XSLTProcessorFactory java.lang.NoClassDefFoundError: org/apache/xalan/xslt/XSLTProcessorFactory at org.apache.tools.ant.taskdefs.optional.XalanLiaison.init(XalanLiais on.java) at java.lang.Class.newInstance0(Native Method) at java.lang.Class.newInstance(Class.java:237) at org.apache.tools.ant.taskdefs.XSLTProcess.setProcessor(XSLTProcess.ja va:210) at org.apache.tools.ant.taskdefs.XSLTProcess.execute(XSLTProcess.java:13 3) at org.apache.tools.ant.Target.execute(Target.java:142) at org.apache.tools.ant.Project.runTarget(Project.java:818) at org.apache.tools.ant.Project.executeTarget(Project.java:532) at org.apache.tools.ant.Project.executeTargets(Project.java:506) at org.apache.tools.ant.Main.runBuild(Main.java:420) at org.apache.tools.ant.Main.main(Main.java:149) Total time: 9 seconds
Re: Iterating a ResultSet
On Thu, 28 Dec 2000, Ted Husted wrote: I'm thinking that the Action could grab a connection from the pool, and generate a statement based on the bean's query string, store the result in the bean's ResultSet, punch the rows we need into the collection, and foward it on to the form, where the interate tag could run it through the iterate tag. So can you clone a ResultSet? The last time I looked into this I found that you have to maintain the Connection you used to obtain a ResultSet until you've finished iterating through it. If you close the connection, you lose the ResultSet. If you can clone a ResultSet, close the connection, and then later iterate the cloned ResultSet, I'd sure like to see how to do that. In lieu of cloning, I store a ResultSet in another object and then pass this new object along by firing an event. Problem is, my formulation is not a generic solution. But it does have the advantage that I can return the connection to the pool sooner and it confines connection handling to one method.