Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with a sample Login/Logout in Sturts2

 
Faisal Fuad
Ranch Hand
Posts: 83
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am new in Struts2. My question is, in Struts2 why we are keeping "sturts.xml" file into /src (may be I am wrong but thats the way I am seeing in most of the online examples)? Don't you think it will cause problem when we will create EAR (based on our current project) to deliver...because in EAR, it is keeping only the binary (.class) files-right?

Secondly, I was trying to create a simple Login/Logout process based on an given example in Rose India. Mainly was testing whether I understand the concept or not but still not successful 100% Can any one please help me to find my mistake(s).

Problems are:

a) It is not reading values from the common.properties file
b) Sometimes the App is working and sometimes not (websphere is upset)

Errors I am getting are as follows (in my console)"











My Files are as follows:

(a) common.properties

(b) Login.java

(c) Logout.java

(d) index.jsp

(e) success.jsp

(f) struts.xml

(g) web.xml


 
Joe Ess
Bartender
Pie
Posts: 9264
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Faisal Fuad wrote:Hi, I am new in Struts2. My question is, in Struts2 why we are keeping "sturts.xml" file into /src (may be I am wrong but thats the way I am seeing in most of the online examples)?


Your build must put the struts.xml file in the classpath of your application at build time. The most obvious place would be in /WEB-INF/classes in the WAR or EAR file.

Faisal Fuad wrote:
Secondly, I was trying to create a simple Login/Logout process based on an given example in Rose India.


Rose India is notorious for bad example code. You would be better off following the examples packaged with the Struts distribution.

Faisal Fuad wrote:
a) It is not reading values from the common.properties file


There are rules for naming properties files. I usually use "MessageResources.properties" for common properties and place it in the same location as struts.xml.

Faisal Fuad wrote:
b) Sometimes the App is working and sometimes not (websphere is upset)


Those errors looks like a bad WAR or EAR file. Unfortunately, I have no experience with Websphere. Is your build completing successfully?
 
Faisal Fuad
Ranch Hand
Posts: 83
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe, I don't wanna give you "Thanks" right away! Rather let me tell you the steps I went through. After reading your reply...I clicked on your given link for "Rules for naming Properties Files". I read one line...then two....then three.....and till now, still reading. Wonderful! So clear and beautiful explanations on everything...everything about Sturts2. It seems like the site itself is talking to me and whatever questions I was having, having now their clear asnwers! As an example, I didn't know that in Struts2, the framework do search our Resource Bundle in a specific order (besides their nameaning convension). Isn't that exciting...!!!

Look, I know there is a lot to finish now but each time whenever I am getting some new ideas while reading, automatically saying "Thanks Joe". The problem related to this post is now over. Everything is running fine. Websphere is happy as well as I am

Wishing you the best Sir.

Regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic