Bruce Steinback

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

Recent posts by Bruce Steinback

Hi all,

Sorry to bother, but I've hit a wall on this one. I'm trying to upload a file using a Struts servlet, but ServletFileUpload comes up with an empty list. Here's my code:



I looked at the response using Fiddler and it looked fine (I can include if if people think it's useful).

So I put in all the log statements to try to figure out what went wrong, but they all look fine:
RequestType = POST
Req content-type is: multipart/form-data; boundary=----WebKitFormBoundaryfgssIVuNZTKaXZpA
req length=234315
file dir = C:\Program Files\tomcat5\apache-tomcat-5.5.28\temp
SizeMax & FileSize are both -1 (should mean no limit, right?)

Anyone have any idea what I'm doing wrong? There's a note about parseRequest() coming up empty if the request has already been processed. Could this be because of Struts (using Struts 2)? If so, anyone know any way around that?

Many thanks in advance,
Bruce
13 years ago
And it works! Case closed. Thanks for the confirmation.

Bruce
14 years ago
Actually, I just found something encouraging in the Struts2 MailReader App, that was along the lines I suspected. They added the following to the web.xml:

<listener>
<listener-class>mailreader2.ApplicationListener</listener-class>
</listener>

and then have a:

public class ApplicationListener implements ServletContexxtListener

with contextInitialized() and contextDestroyed() methods that appear perfect for my needs! I'm trying it out now.

If anyone has any thoughts or comments do let me know, else I'll call this closed.

Bruce
14 years ago
dumb Q (but I can't find an answer anywhere)...

I need a place to hang my application initialization code (e.g. connect to Tomcat DB Pool, start logging, ...).

When using Servlets I used:
class MyServlet extends HTTPServlet {
public synchronized void int() { ... my init code ... }

In Struts1 I had:
class myAppActionServlet extends ActionServlet {
public void init() { ... my init code ... }

but it appears that I have neither of these available in Struts2, so where do I hang my init code?

I'm sure I'm missing something stupid, but....

Many Thanks in advance,
Bruce
14 years ago
Whoops! Should have replied first I guess. Still learnin' the ropes here.

FYI, it was mostly my stupidity. I had tried putting struts.xml in the classes directory, but having gotten an exception (and no obvious error in the WEB-INF directory) I made the incorrect assumption that the classes directory was wrong (I had an error in my XML file that caused the exception).

Anyway, all's well now. Thanks much, David, for the help, and the cool tool - config-browser helped me get my namespaces right.

Cheers,
Bruce
14 years ago
Sigh, curiouser and curiouser. No change with commons-io-1.4.jar in the /lib

The struts site suggested that config-browser was bundled in the struts.jar, but when I tried putting in the sugested URL:
http://localhost:8080/hw3/config-browser/index.action
(I also tried several variations, which had even worse errors)

I got the error
There is no Action mapped for action name index.

I'd thought that setting logger to DEBUG only affected my own logging statements, but I'll give it a try and let you know

Sigh,
Bruce
14 years ago
My, you're up early! (or is it just that I'm on Pacific time?)

Alas, I didn't appear to get any extra info out of setting devMode=true in struts.properties (I even checked that the properties file was being read by intentionally messing up a setting)

Here's my list of JARs in my /lib dir:
commons-dbcp-1.2.2.jar
commons-fileupload-1.2.1.jar
commons-logging-1.0.4.jar
freemarker-2.3.15.jar
mysql-connector-java-3.1.7-bin.jar
ognl-2.7.3.jar
struts2-core-2.1.8.1.jar
xwork-core-2.1.6.jar

Many thanks for trying to help! I'm utterly stumped.

Bruce
14 years ago
Thanks for the quick response. Sigh, alas I'd also already tried that. But to be safe I tried again - only change in struts.xml:
<package name="default" extends="struts-default">

same result But please keep trying.

Curiously, I get tomcat log lines:

INFO: Unable to locate configuration files of the name struts-plugin.xml, skipping
Feb 25, 2010 8:58:33 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file [struts-plugin.xml]
Feb 25, 2010 8:58:33 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Unable to locate configuration files of the name struts.xml, skipping
Feb 25, 2010 8:58:33 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
INFO: Parsing configuration file [struts.xml]


not sure what they mean, if anything. Interestingly, I have no struts-plugin.xml file, but do have a struts.xml

One small amount of good news: I found that I could turn off form formatting with theme="simple" in the FORM field. Hey, at this point I'll take any success i can get.

Sigh,
Bruce
14 years ago
Sigh, this shouldn't be difficult, but...

New to Struts2 and just trying a simple test program with little success. I've got a JSP welcome page, but tomcat (5.5) is giving a WARNING when I access the page:

WARNING: No configuration found for the specified action: 'showBooks' in namespace: ''. Form action defaulting to 'action' attribute's literal value.

and when I submit the form I get:

There is no Action mapped for namespace / and action name showBooks.

I've read articles and archived topics until I'm cross-eyed, tried about a hundred variations, and none of them work. Here's the latest:

web.xml:


struts.xml (also tried struts-config.xml):


and finally request.jsp:



I've also tried adding a namespace to the s:sbumit, but with no luck either.

It's GOT to be something really stupid, but it's eluding me. Any assistance would b gratefully accepted.

Thanks in advance,
Bruce

oh, P.S. Not as critical, but also annoying: I want to be able to format my own forms (yeah, I know the above sucks, but it's just testing). I put the suggested:
<constant name="struts.ui.theme" value="simple" />
in my struts.xml, but it doesn't seem to have any effect. Struts is still trying to format my form. Any ideas? (if it's bad form to put multiple subjects into a topic I'll submit it separately).
14 years ago