aspose file tools*
The moose likes Struts and the fly likes Problem with a sample Login/Logout in Sturts2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with a sample Login/Logout in Sturts2" Watch "Problem with a sample Login/Logout in Sturts2" New topic
Author

Problem with a sample Login/Logout in Sturts2

Faisal Fuad
Ranch Hand

Joined: Jul 05, 2011
Posts: 79

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

Joined: Oct 29, 2001
Posts: 8908
    
    8

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?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Faisal Fuad
Ranch Hand

Joined: Jul 05, 2011
Posts: 79

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
 
 
subject: Problem with a sample Login/Logout in Sturts2