• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

In a MVC design is it possible to automatically invoke a Command upon page load?

 
Jonny Devine
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using a MVC pattern for my application. It has a FrontController, Command, Service, and DAO. For my application to process requests/responses it has to send a command to the FrontController - this is usually done via get/post requests.

The problem im having is that I want to display a list of users (and their avatars) on my homepage. How do I get my jsp page to automatically call the ListMembers command upon page load without get/post request?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your home page is displayed without the use of a GET or POST request? I don't think so.

The display of your home page should be the result of a command like any other request.
 
Jonny Devine
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Your home page is displayed without the use of a GET or POST request? I don't think so.

The display of your home page should be the result of a command like any other request.


That's the thing, I don't know how it works? When the user goes to www.website.com/index I want to display a list of members. It works when the user goes to www.website.com/index?action=ListMembers but I want it to work when the user just goes to the index page without any parameters in the URL? How do I get the command "ListMembers" to be invoked upon index page load?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to find out what /index is mapped to. Do you really mean /index? Or do you really mean /index.jsp?

You may want to check the deployment descriptor for a mapping of /index or a welcome-file declaration.
 
Jonny Devine
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:You need to find out what /index is mapped to. Do you really mean /index? Or do you really mean /index.jsp?

You may want to check the deployment descriptor for a mapping of /index or a welcome-file declaration.


Sorry I meant /index.jsp. My FrontController strips the .jsp.

So in order for my index.jsp page to invoke the ListMembersCommand upon page load I have to add a mapping to the deployment descriptor to presumably a servlet? Thing is ListMembersCommand is not a servlet. Only my FrontController is a servlet and that is already mapped in the DD. Am I getting that right?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure that there is no index.jsp page, and then add the URL to the homepage's action as the welcome-file. If someone types the URL without a path, they will be directed to the home page command. If they type index.jsp, they'll get a 404 like they should.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic