Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Richard Carrot

Greenhorn
+ Follow
since Nov 01, 2017
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
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Richard Carrot

Hi all,

I have been getting to grips with struts again which is something I've been doing for a while lol I have an issue, perhaps somebody could enlighten me. I decided that after understanding the concept of XML configuration I would attempt zero configuration. First off zero wasn't to bad, instead of a struts.xml I had a struts.properties which set constants for struts configuration. This was all ok. I integrated Hibernate with a MySQL database and developed a page which pulled some data out of one of the MySQL test databases and presented in an iterable table on a .jsp. I also messed around with jquery plugin and datatables, all ok. I then decided that I wanted to understand more about user authorisation so I thought I would create a simple login etc as you do. I wanted the login form to be presented at http://localhost:8080/test/login with no action extension configurable with a constant. I got to grips with the convention plugin scanning package names and classes that extended ActionSupport.

The problem I had was that I could not seem to figure out how to render a .jsp with the form on at http://localhost:8080/test/login then submit that form using the same action but a different method. As execute would have given a success result which sent the user to /test/login. I read the struts website about post back default but I was unable to get that working, Im not sure why. So I read on stackoverflow that you could do it but that the only other way of achieving this was to use the struts rest plugin. So off I went down that rabbit hole. Downloaded the sample application and got to grips with that and now I have a login form at test/login. But I had to revert to using a struts.xml due to global allowed methods.

The next hole that I want to go down is to look at security for the login but I don't like the idea of using spring security with struts seems backwards why not just go and use spring or is struts better than Spring. Spring seems like another headache after the headache getting this far with struts.
1 year ago
Yes I believe you are correct. I've been able to make some progress. I changed the controller method to this and added the following to a .jsp all seems to be working.



and the .jsp



onto the next thing to solve
2 years ago
The code snippet is from a pluralsight tutorial spring and JDBC, I think his name is Bryan Hansen.
2 years ago
I'm new to spring and was wondering whether someone could help me figure out an easy problem which I cannot.

I have the following method in a controller which I would like to display the data from, on a .jsp. The code is from a tutorial that I've been following however the tutorial doesn't seem to be talking about how the data ends up on the .jsp. I want to display the data in a table on a .jsp which is not how it works at the moment.


2 years ago
Hi all,

I have been learning spring from a tutorial and it has all been going ok up until a short while ago. The application was running this morning and then I followed the tutorial a little more and now the whole application wont run. I'm getting the following error:



I removed all this mornings tutorial parts and that has not had an effect. I would have thought that retracing my steps and removing what was added would have made the application run again but no luck.

I'm working with Tomcat8.4, eclipse, building a maven project dependencies pom.xml as follows:



I have commented out the hibernate validator as this was the part of the tutorial where I had got to. Any ideas would be greatly appreciated?
2 years ago
For something that should be quite straight forward getting struts to work has been a pain in the arse.

After some fishing on stackoverflow here

I found that JDK9 and struts are not friends...so I kept on trying to get this to work and downloaded JDK1.8, that didnt work either. Does anyone else have problems running with struts if they dont could someone let me know what configuration they are running please. Im back getting a SEVERE exception starting filter struts2

2 years ago
Right I have found a group of jars from an example folder that I added to the build path and tomcat has started with no immediate errors. I also land on an index.jsp however when I envoke an action from a form on the index.jsp it takes me to a 404 not found with no error message in the console. I guess that means that struts isn't really working after all. I'm very confused now. The .jars that stopped immediate tomcat errors are as follows:

commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
commons-logging-api.1.1.jar
freemarker-2.3.18.jar
javassist-3.11.0.GA.jar
ognl-3.0.4.jar
struts2-dojo-plugin-2.3.1.2.jar
xwork-core-2.3.1.2.jar
commons-lang3-3.2jar
struts2-core-2.5.13.jar

I was wondering whether anyone could shed on light on my new problem?
2 years ago

Dave Tolls wrote:Looking at that tutorial I notice there's no date for it, which is annoying as you can't tell which version of Struts it was aimed at.
2.5 only came out as a release 18 months ago, so it's possible that tutorial is out of date.



Yes, the tutorial is out of date. Getting the following error still:


2 years ago
I have spent ages trying to get this work now. I have tried numerous configurations and I still can't get it to work.

I'm currently stuck back on a previous error that I posted.



I have tried all the filter options

 <!--   org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter -->
   <!-- org.apache.struts2.dispatcher.FilterDispatcher -->
          org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter

as I read that this has been deprecated and I should be using the last version with the latest version of struts.

I download the struts 2.3.4 package and tried to use a selection of jars from that .zip, didn't work.

I'm using the following .jars

commons-beanutils-1.9.2.jar
commons-fileupload-1.3.3.jar
commons-io-2.5.jar
commons-lang-2.4.jar
commons-lang3-3.6.jar
commons-logging-1.1.3.jar
freemarker-2.3.23.jar
javassist-3.20.0-GA.jar
jcl-over-sl4j-1.7.6.jar
log4j-api-2.8.2.jar
ognl-3.1.15.jar
sl4j-api-1.7.12.jar
struts2-core-2.5.13.jar
xwork-core-2.3.4.1-sources.jar (This .jar is not part of the latest struts \lib folder, I downloaded it separately)
asm-5.2.jar
asm-commons-5.2.jar
asm-tree-5.2.jar

Feel like I've been going round in circles for hours...
   
2 years ago
newest error now as follows:

2 years ago
Ok I have just added a few other jars to my build path:

Build path is as follows:

commons-fileupload-1.3.3.jar
commons-io-2.5.jar
commons-lang-2.4.jar
commons-logging-1.1.3.jar
freemarker-2.3.23.jar
javaassist-3.20.0-GA.jar
ognl-3.1.15.jar
struts2-core-2.5.13.jar
commons-lang3-3.6.jar
jcl-over-sl4j-1.7.6.jar
log4j-api-2.8.2.jar
slf4j-api-1.7.12.jar

Tomcat starts and then throws and HTTP500 file invalid path exception



2 years ago

Dave Tolls wrote:Well, there's this old thread from here:
https://coderanch.com/t/544629/framework/java-lang-ClassNotFoundException-org-apache

That might point you to which jar files you actually need to include.



Thanks, that did help. I have cut down the number of .jars added to WEB-INF lib however I have a new error now using the following .jars

commons-fileupload-1.3.3.jar
commons-io-2.5.jar
commons-lang-2.4.jar
commons-logging-1.1.3.jar
freemarker-2.3.23.jar
javaassist-3.20.0-GA.jar
ognl-3.1.15.jar
struts2-core-2.5.13.jar

Running Java 9 & Tomcat 8.5 with the web.xml struts 2 dispatcher filter setup like

org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter

Am now getting the following error:



Perhaps I need other .jars that I'm not aware of. I've been following a tutorial on Struts2 here
2 years ago

Dave Tolls wrote:
So, is the InjectedObjectContainer class on the class path at runtime?



I dont have an InjectedObjectContainer class. Not sure I understand that?

Dave Tolls wrote:Is the jar file it is in being deployed to the webapps/<your app>/WEB-INF/lib directory in Tomcat?



I downloaded Struts-2.5.13 and added all the .jars (probably don't need all them for helloWorld) to the build path. The build path contains these and

JRE System Library [jre-9.0.1]
Apache Tomcar v8.5 [Apache Tomcat v.8.5]
Web App Libraries
EAR Libraries

none of which are ticked.

cheers
2 years ago
Hi I'm trying to get a simple struts 2 application to run using eclipse oxygen, java 9 and tomcat 8.5. Upon running tomcat I'm getting the following error:



I'm using the following filter org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
2 years ago