Design problem: MVC

A

Albert

Well, I'm developing a website where the content is dynamically
included.It's my first jsp project so I've got some - probably basic
-questions.
A jsp page is divided in some areas like content, navigation etc.
Content -as an example - is dynamically included and should display some -
I call them - blocks.
A block is for example an image, a list and a headline. So content can
have 1 to many blocks.
So a page ->content->block->image
I'm using the MVC pattern so my first approach was that my controller
servlets passes to the jsp page an object called model and the jsp page
gets
the data out of it.
Because of the structure this gets very ugly like:
Page onepage = (Page) model.getPage();
and then
(Area) onearea = (Area) onepage.getArea('content');
and so on...
The second problem is how do I pass the needed objects to the includes..?
Actually the jsp-page gets the object and writes it into the request with
setAttribute and the included page pulls them out..
But this looks horrible..
Thanks for any advice!
 
A

Andy Hill

Albert said:
Well, I'm developing a website where the content is dynamically
included.It's my first jsp project so I've got some - probably basic
-questions.
A jsp page is divided in some areas like content, navigation etc.
Content -as an example - is dynamically included and should display some -
I call them - blocks.
A block is for example an image, a list and a headline. So content can
have 1 to many blocks.
So a page ->content->block->image
I'm using the MVC pattern so my first approach was that my controller
servlets passes to the jsp page an object called model and the jsp page
gets
the data out of it.
Because of the structure this gets very ugly like:
Page onepage = (Page) model.getPage();
and then
(Area) onearea = (Area) onepage.getArea('content');
and so on...
The second problem is how do I pass the needed objects to the includes..?
Actually the jsp-page gets the object and writes it into the request with
setAttribute and the included page pulls them out..
But this looks horrible..
Thanks for any advice!
Instead of re-inventing the wheel, have you looked into using Jakarta Struts?
It's already an MVC architecture (well, in a manner of speaking, anyhow), and
addresses most of the problems you've posed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

mvc design doubts 9
spring mvc question 0
MVC design questions 25
MVC philosopy question 10
MVC Design Pattern 4
MVC WEBFORM INTEGRATION 1
Clickable Div Block 1
GUI design in simulation: or MVC pattern usefulness? 7

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top