For my college project I have to build a custom JSP/Servlet MVC application so I can't use frameworks such as Struts or Spring. I already have FrontController, Command, Service, DAO, Business layers.
Let's say I want to create a website with a sidebar and in the sidebar has the following widgets: Members
, Who's Online
, Recent Comments
. Each widget accesses the database via Command
-> Service
-> Dao
.
I want information to be displayed in the sidebar constantly throughout the application. Problem is I don't know how to do this. I know how to display information by processing GET/POST requests but I don't know how to display information (from database) without GET/POST requests if that makes sense?
Couple of ways I tried that don't work:
1) Upon loading the homepage
and invoking the HomeCommand
calls ListUsers
from UserDao
and then stores them into a session. But if the user enters the site from a different URL ListUsers won't be stored into a session.
2) Creating a separate Command
: MembersCommand
, WhosOnlineCommand
, RecentCommentsCommand
. Then use JSTL
include
to include the FrontController
and to get it to invoke the Command
. But include wants a .jsp
<jsp:include page="FrontController/members" />
Fragment "FrontController/members" was not found at expected path /MyApplication/WebContent/WEB-INF/FrontController/memmbers
3) Create individual .jsp's
for each widget (members.jsp
, whosonline.jsp
) with Java code to access the Dao
. Then use JSTL include
. But how would I get it to go through the FrontController
and isn't Java in jsp's a big no-no?
4) Use <jsp:forward page="" />
but this gives me a blank page?
I'm out of ideas?