Designing presentation layer servlet classes

2

2BaCook

I was wondering when writing a basic web program (typical 4-tier
architecture) having a presentation layer that all extends
HttpServlet... why not have a class BaseUI that extends HttpServlets
and then have all my other UI classes extend from BaseUI? I have seen
examples in texts just showing each UI class to extend just from
Servlets, so I figure this is wrong but I do not know why.
Thanks!
 
V

VisionSet

2BaCook said:
I was wondering when writing a basic web program (typical 4-tier
architecture) having a presentation layer that all extends
HttpServlet... why not have a class BaseUI that extends HttpServlets
and then have all my other UI classes extend from BaseUI? I have seen
examples in texts just showing each UI class to extend just from
Servlets, so I figure this is wrong but I do not know why.
Thanks!

I take it you not rendering in a browser?
 
J

John C. Bollinger

2BaCook said:
I was wondering when writing a basic web program (typical 4-tier
architecture) having a presentation layer that all extends
HttpServlet... why not have a class BaseUI that extends HttpServlets
and then have all my other UI classes extend from BaseUI? I have seen
examples in texts just showing each UI class to extend just from
Servlets, so I figure this is wrong but I do not know why.
Thanks!

The question of specific technology choice aside, yes, you could do
that. But why? What do you stand to gain?


John Bollinger
(e-mail address removed)
 
R

Reinhold Erler

2BaCook said:
I was wondering when writing a basic web program (typical 4-tier
architecture) having a presentation layer that all extends
HttpServlet... why not have a class BaseUI that extends HttpServlets
and then have all my other UI classes extend from BaseUI? I have seen
examples in texts just showing each UI class to extend just from
Servlets, so I figure this is wrong but I do not know why.
Thanks!

I don't think it's wrong to use a superclass for all servlets (there's only
an insignificant loss of performance). but I'm wondering about servlets as
UI classes. Usually a state-of-the-art application separates the model
(business logic, database access) from the view (generating the html
output). therefore you could consider using the servlets for executing
business logic and forwarding the request to jsps for presentation.
Additionally you would gain flexibility by using some MVC framework like
Struts or similar.

Reini
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top