Tuesday, June 3, 2008

Fresh Sample Application for Struts 2 in Action

I've just sent the new version of the sample application over to Manning. I'm not sure how long it will take them to post it to the book page. But it shouldn't take long, day or two at the most I imagine. This new version features:

  • Separate HelloWorld.war
  • Cleaner source code
  • Better comments
  • Revised README
Hope this helps. Make sure to read the README ;)


Chad Davis said...

The new sample app has been posted.


alf said...

I come from China, but, I cannot get your code.beacause , cannot visit Manning Site.Why?
I am a fan of Structs2,learning your book.

Chad Davis said...


Is this still true? You should be able to get the download regardless of where you live.

Anonymous said...

Good book. It will be nicer if you will provide the examples for the rest of chapters too.


Chad Davis said...


Which chapters are you referring too?

Anonymous said...

Book has 15 chapters but SampleApplication.zip(Struts2InAction.war) has only Eleven...

Scott Stanlick said...

Greetings earthlings! It is Scott coming to you from the mother ship. Someone was asking about the sample code for the advanced chapters and I would like to report that this was purposeful and deliberate. *YOU* need to experience these capabilities kinetically, and that means "finger learning!" You cannot really learn these things from copy/paste.


Anonymous said...

Hi "mother ship",

Here is the anonymous reader/writer. Don't worry about students - they can learn from anything...

Chad Davis said...

I'm not sure what you guys are even talking about :)

Anonymous said...

Hello Mothership... Your comment "You cannot really learn these things from copy/paste." is not altogether true. For those of us with ADD or similar may find it difficult to get everything from the text. I, for one, find it much easier to learn from examples. I read what I can in the book then refer to the examples for final clarity. I would find great value in sample code for the advanced chapters.

Hate to crash & burn your ship ;)


Anonymous said...

Mr Chad Michael Davis, hello
I am engineer at the "caisse nationale de sécurité social" of Tunisia.
I am a developer JEE. I have read your famous book Struts 2 in Action.
I have not been able to excécute the chapter 11 on an Oracle database view you use a table called "user". it's not possible to create this table in oracle.
Can you help me? you have a version of source code that uses an Oracle database.
Thank you very much in advance, I wish you a good day.

Chad Davis said...


Starting with the Chapter 9 version of the sample application, the code all uses Hibernate/JPA. First, these technologies do work on Oracle, I assure you.

Second, can you be more specific about what you mean by Oracle can't use the table "user"?

Anonymous said...

Sorry Mr,I tried to run the chapters 9, 10 and 11 but without any succes.

The problem just because the word "user" is a reserved word for oracle.

Thus i run simple application on Oracle technology, portfolio_image table and portfolio table are created, but not the user table.

I think we should change the name of the table user by another in all the source code.


Chad Davis said...


I see. Hmm. I see. So, you can probably just change the table name used by Hibernate and it will be fine. But I'll have to think about this a bit, there might be some other reprecussions I'm overlooking.

If you do this, please get back with how it goes. I'll eventually make an Oracle friendly version of the sample code. Unfortunatley, I can't just change the entire sample app because it needs to match to text of the book.

I wish you would have been a reviewer; maybe you would have found this before the book went to press. I actually use Oracle everyday. But I never tested the sample app on Oracle.

Anonymous said...

Mr Scott Stanlick, hello
I am really sorry to mention this problem. My only goal was to set up your application with Oracle to provide extensions and leave on good standard JEE. Unfortunately, I have this problem.
You can build a version of your application with many details using the oracle. This solves the problem.

drucker said...

Hello Mister Chad

I have just begun in Java web development
I bought your book "Struts 2 in Action" wich i think is one of the best Struts 2 book's.
I download Sample Application code
i wanna change the code and redeploy the application "helloworld" to do so i need a build file
i don't know how to make one ,i need your help to provide me with a build file (i'm using Apache Tomcat 6.x) and/or give me advises or docs to learn how package&deploy java web app's.

best regards

Chad Davis said...


If you are new to java web apps, I'd highly recommend the straightforward tutorial found in the tomcat docs.


This shows you how to use ant for builds, and explains all the high level tasks involved in building a java web app.

drucker said...

thank you good idea i 'm reading now tomcat doc , and i understand better the whole structure of java web apps, but still can't found a build.xml example that i can customize to sample Application code of "Struts 2 in Action"

that would be appreciated if u can give the build that u used to helloworld app

this my e-mail "rassidm@gmail.com"

Best regard

Chad Davis said...

I didn't use an ant build for the sample application. I used an eclipse tomcat plugin from sysdeo. I can't say I'd necessarily recommend it.

I would recommend creating your own ant file to do what you want. It's not that hard. I'd do one myself for you, but I'm pretty busy right now. Sorry.

drucker said...

thanks anyway I'll follow your advise
good luck ;)

Anonymous said...

I live in China and I am unable to access the manning website to download the source code for Struts 2

Chad Davis said...


I'm sorry that you can't get the sample application. What can I do? Why aren't you able to get it?

Michael said...

Thanks for the quick response to my post about living in China. When I type in www.manning.com it looks like it will connect but, it just sits there until finally I get www.manning.com is taking to long to respond request timed out. Either manning.com is blocking ip addresses from China or China is blocking manning.com. Both of which I have encountered while living here. I am reading the book on Safari right now. It is a great book and it is giving me good understanding of struts 2. I usually like to read books that include the source code in the book so that I can type it in myself. That really gives me a good grasp of what's happening. I am a do and learn kinda guy not a read and learn kind. Anyways I just wanted to let you know the book is really good. Do you think that you could email me the source code?
Mike in China

Chad Davis said...


I just spoke with Manning. They don't know of any reason why you wouldn't be able to get to their site.

Please let me know if this continues and I'll try to make the sample code available from another site.

Michael said...

I worked around the problem. I setup a proxy server on a computer I have in the states. Then connected through the proxy to the manning site.

Mike in China

Saurin said...

Hi Chad, Have been reading your book Struts2InAction. Really really well composed book. Struts2 is looking really easy with it. Downloaded your sample app. I am using Eclipse Ganymede as IDE and ofcourse Tomcat 5.5 as server.All is going good in the sample app except AjaxBrowser when run in IDE. Clicking 'Artist Browser' link on chapter eight, I am getting blank page. Would be good if you help me fix it. Pl. reply if you need more details. Thanks.

Saurin said...

Hi Chad, that has been fixed. needed simple change in html code for including js file. I had a question... If a action implements both SessionAware and RequestAware, What will their setter method code. Will it be like for Session we define arg0 and for request we define arg1?? In what order it is to read? For eg. Session will arg0 and request will be arg1 if you define SessionAware First and then RequestAware?? Or it is something completely other way to do that???

Chad Davis said...


Not sure I follow your question about SessionAware and RequestAware. These interfaces both require that you write the specific setSession or setRequest setter methods, that each take a Java Map object. This map contains all of the data in the session or request scoped maps, which basically means the stuff in the servlet session or request scope.

Am I'm missing something?

GeekDude said...

I can't see any links are working here.I have a Basic Struts Login Application program using Strus1.2. I think this will also very helpful to your blog followers.

Gaurav Agam said...

I can't download sample application. Starts download but only 1 mb file getting downloaded.