• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which is Model and Controller in this example?

 
Aditi Gandy
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am new to struts2. I have followed an example from www.roseindia.net.
my code goes here.

Login.java code goes here (action class)

action mapping is done in struts.xml code goes here:

I know that jsp is used for view-purpose. Now, i wanted to make out which is Model and controlloer in my above example.

Can any one please help me??

Regards,
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The controller proper is the Struts 2 filter. Struts 2 actions can act as both a model and "sub-controller". Note that the MVC pattern is a term that's somewhat abused in the web development world and the boundaries between layers aren't always as clear as they are in a pure MVC design.

As an aside, note that your comments have lead to a documentation error--the // ---- Username comment is made twice. Also, the <p> tags around the first sentence in JavaDoc comments are redundant, and make it harder to read. It's also arguable that the name of the method is in itself enough documentation. Lastly, a string's default value is already null; setting it explicitly is redundant.

Consider instead simplifying the source:



It's half the size, easier to read, and produces essentially the same JavaDoc output: simple setters and getters that perform no other function other than setting and getting values don't really need any other documentation other than their name. IMO essentially no information has been lost, and it's half the size.
[ December 23, 2008: Message edited by: David Newton ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic