Help coderanch get a
new server
by contributing to the fundraiser

Rick Herrick

+ Follow
since Aug 25, 2004
Merit badge: grant badges
For More
Webster Groves, MO
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rick Herrick

OK, the important change was removing the "/" from the getResource() call:

What's interesting about that is that, in my Struts action class where I initially placed David's sample code, the version with the leading slash did work. So that's strange. But OK.

Now the next strange thing is that I find which is used and even after I turn all of the settings in that file to FATAL, I still get tons of debug messages. What seems to unite these, though, is that they're all Struts messages. Is there some sort of Struts debug or tracing facility separate from log4j? It uses the commons logging stuff, I know that, but doesn't that just grab whatever's around, with a strong prejudice for log4j?
19 years ago

I had thought of that and actually ran a batch "jar tf" on all of the jar files that I could find on the classpath. No luck.


A most excellent suggestion that yielded useful information that, unfortunately, hasn't helped me solve the problem. I modified your code a bit to walk all the way up the class loader hierarchy:

I find that the only that is available is loaded by the web app classloader. So I've tried to add it by force at various points in the classpath, to no avail. I've tried adding this same discovery code to Tomcat by disassembling Bootstrap.class and replacing it in the jar, but there I see no evidence of the resource being added to the catalinaLoader, commonLoader, or sharedLoader, even though I have it in the classpath. The complication is that it doesn't seem like anything ELSE is getting added to the classpath, so something very strange is going on.

I'll post a follow-up when I figure out what's going on!
19 years ago
I'm having a problem when starting up Tomcat that's led me to a more philosophical question. The immediate problem is that Tomcat starts up with the log4j logging level set to DEBUG. This means I get EXTREMELY verbose information from places I quite frankly don't want to know about. The problem is that I've gone through and located EVERY file that I can find and renamed them all and yet I still get this behavior. This means that I can't turn this level down.

So the philosophical question is, how can I determine which version of a particular resource file is getting picked up by something? I'd like to solve the immediate problem of turning down my debug level and the longer-term problem of knowing which properties file Tomcat is getting its hands onto. I really think it'd be awesome if the first thing log4j did is spit out which file it was using (if it can do resolve that, anyways).

And yes, I've tried looking along the explicit classpath set in the catalina start-up script (batch file in my case, since I'm on W2K).

Any info would be greatly appreciated.
19 years ago
I just ran across this while looking for info on using the Commons FTP package. You may want to try setting your connection to passive. A lot of the issues that people have had getting info properly through the FTP connection have related to firewall issues, which can be (somewhat) circumvented by using a passive instead of active FTP connection.
OK, thus far, I've answered one of my own questions before anyone else and here's another

This is a vexing problem with a really simple solution! Make sure that you set the enctype properly in your html:form element:

That did it for me.
19 years ago
I'm getting this same error, but I have (what I believe to be) the proper getter and setter methods for the file uploads. I have this in my JSP page:

(with all the other necessary stuff; this page is currently working except for the upload section).

Then in my form bean, I have:

I then get the exception:

If I comment out the file controls, I have no problems submitting the form. With the file controls, I can't submit the form, even when I'm not uploading a file.

Any ideas would be great! Argument type mismatch? What argument? What types? This info would be helpful
19 years ago
And one other thing, which sreenath showed but didn't really point out. For your parameter check, keep in mind that '==' for Java Strings won't do what you want it to there (it does an Object compare as opposed to a string compare), so you need to use the String.equals() method. So your snippet of Java code would actually look like this:

You also should really check that you actually got a value for these parameters before calling the equals() method, meaning that this becomes:

That's all...
19 years ago
If I understand your question correctly, you can just check for valid combinations of incoming data in your action handling the form. If you don't find a valid combination, create an ActionErrors object, add an ActionError to that ActionErrors collection, save the errors with the Action.saveErrors() method, then return the appropriate action forward (back to the same form, for example). Check out the struts-example web app that comes with Struts and you'll see how to do that fairly easily.

Alternatively, you can add the validation to your form class, which is probably really the appropriate way to do it. But I don't know enough about how to do it to tell you how to proceed. Again though, if you look in the struts-example, there's code that shows how to do this for a couple of different forms. I had attributes that had a number of weird complex validation rules that made it difficult to do that in a straightforward way, so I just did it in the form handler. Learning the XML validation rules set up is the next task
19 years ago
OK, never mind! I've figured it out. It is NOT wildly obvious!

What you do is add two extra get/set methods for each Map property that you have. These methods should look something like this:

Now, in the form that you want to submit (i.e. that you want to have contain controls to hold the data so that it's passed back and included in the newly created bean for the submit handler), do something like this:

In the generated HTML, you'll see something like this:

Now, when you click the Submit button, if you look at the form object passed into the action class that's handling your form, the Map property is properly initialized. Whew. That was rough.

If you're interested in using this, I wrote up a little sample app to test it out. Hope this helps anyone having similar problems!
[ August 25, 2004: Message edited by: Rick Herrick ]
19 years ago
Here's a followup. I've continued to look for a solution to this and found this: (search down to Mapped Properties)

Basically, this doesn't work, unless I'm really missing something. I added a property, along with getter and setter, called objectMapped to my form class. As I sort of expected before I even started, Struts didn't like this. I got the message:

No getter method for property objectMapped(xxx) of bean testForm

where xxx is whatever key I'm trying to pass in. So that doesn't work to get the items, and I still have no way to SET the Map keys and values for the submit back to the server and the contruction of the new bean to represent the data from the form.

What it does show is that there's been some attempt to address this in the past, but apparently not adequately enough
19 years ago
I've been working with Struts for only a very short time now, but I have also scoured everywhere that I can think of to try to find an answer for this problem! Hopefully someone will have an idea here (or at least be able to tell me that there IS no solution!).

I have a form bean that has a property that's a Map (stored internally as a hashtable). There's both a getter and setter for the property. When I initialize the bean, I get a bunch of GIDs and names for items stored in a database, using the GIDs as the Map key and names for the values.

This works fine for the display portion of the process. I have a view that displays these items like this:

<logic : present name="promoForm" property="supportFiles">
  <logic:iterate id="supportFile" name="promoForm" property="supportFiles">
    <bean:write name="supportFile" property="key" />: <bean:write name="supportFile" property="value" />
</logic : present>

So this checks that there's a value (in this case a non-null Map object) for the property, then iterates and displays the keys and values.

The problem comes when I submit this form back to the server. Because there's no control for the supportFiles property, that basically returns as null, while all the other attributes that had proper html:* controls are initialized properly.

So here's the core of my question: how can the Map object property be represented in my form with html:* controls so that the set method is called and the property is properly initialized with a Map object?

The only solution I've come up with is to create a bunch of controls like this:

<input type="hidden" name="supportFilesKey1" value="xx" />
<input type="hidden" name="supportFilesValue1" value="yy" />

Then, when the form is posted back to the server, I can go through and look for supportFilesKeyX until such time as that returns null, then turn all of those into a Hashtable and set it. But I'd really rather not. Since there's a way to address the key and value properties of a Map in display, there has to be a way to represent them with controls and have them dealt with properly on the way back in!

Any help on this would be greatly appreciated. If any of this is unclear, just let me know and I'll elaborate appropriately! Thanks!

[ August 25, 2004: Message edited by: Rick Herrick ]
[ August 25, 2004: Message edited by: Rick Herrick ]
19 years ago