| jsp servlet code seperation confusion |
|
| Author |
Message |
Martman

|
Posted: 12/4/2004 8:57:00 AM |
Top |
java-programmer, jsp servlet code seperation confusion
I posted this on the .help NG but I believe you folks could probably
provide more of an accurate answer considering the help group is
targeted towards true beginners.
Okay, where I am employeed I have the options of programming with
Microsoft Technologies and Java specifically J2EE. I have been
investigating the task of learning Java for about the last 3 to 4
months. I am a ASP.Net developer fulltime at work with C#. I was new to
OOP when I started into .Net about a year ago and am getting better.
However, our corporation uses Java as a National standard and I am
looking to advance some day and need to learn Java. Furthermore, where I
live, KY there are very few jobs for technologies other than .Net and
Java. No PHP or ColdFusion.
In the last couple of years this code seperation theory has overloaded
the programming world. .Net does it with what's called code behind. In
my research of Java the only things I see that reference code seperation
is servlets (I am sure J2EE and EJB contribute also). However,
everything I have read on servlets reference outputing HTML back to the
browser via the HttpServletResponse and Request objects.
My question, why in the world do they consider outputting HTML back to a
browser via a servlet considered code seperation. Furthermore, it
seems very time consuming and difficult to hand code complex layouts in
HTML and incorporate/format it for a servlet.
Can someone please explain or direct me to a resource where I can
understand why using servlets at any point in an application would be
better than jsp or even applets? Sometimes it's hard enough to design
complex layouts with the assistance Dreamweaver for example.
Thanks for any insight you can provide, I have read hundreds of pages of
information concerning this and trying to compare it with the my current
knowledge in the .Net world.
Marty U.
|
| |
|
| |
 |
Anzime

|
Posted: 12/4/2004 11:33:00 AM |
Top |
java-programmer >> jsp servlet code seperation confusion
Martman wrote:
> I posted this on the .help NG but I believe you folks could probably
> provide more of an accurate answer considering the help group is
> targeted towards true beginners.
>
> Okay, where I am employeed I have the options of programming with
> Microsoft Technologies and Java specifically J2EE. I have been
> investigating the task of learning Java for about the last 3 to 4
> months. I am a ASP.Net developer fulltime at work with C#. I was new to
> OOP when I started into .Net about a year ago and am getting better.
> However, our corporation uses Java as a National standard and I am
> looking to advance some day and need to learn Java. Furthermore, where I
> live, KY there are very few jobs for technologies other than .Net and
> Java. No PHP or ColdFusion.
>
> In the last couple of years this code seperation theory has overloaded
> the programming world. .Net does it with what's called code behind. In
> my research of Java the only things I see that reference code seperation
> is servlets (I am sure J2EE and EJB contribute also). However,
> everything I have read on servlets reference outputing HTML back to the
> browser via the HttpServletResponse and Request objects.
>
> My question, why in the world do they consider outputting HTML back to a
> browser via a servlet considered code seperation. Furthermore, it seems
> very time consuming and difficult to hand code complex layouts in HTML
> and incorporate/format it for a servlet.
>
> Can someone please explain or direct me to a resource where I can
> understand why using servlets at any point in an application would be
> better than jsp or even applets? Sometimes it's hard enough to design
> complex layouts with the assistance Dreamweaver for example.
>
> Thanks for any insight you can provide, I have read hundreds of pages of
> information concerning this and trying to compare it with the my current
> knowledge in the .Net world.
>
> Marty U.
I haven't looked at .Net at all, so I everything I say is from
a Java perspective.
You wouldn't want to hard code HTML in a servlet; it's ugly, and
difficult to maintain. Servlets are great for non-visual applications
where you need HTTP support (request, response, etc).
When you mention code separation I think you are talking about
separting the "display code", "business logic", and "control logic".
There are many tutorials on the web that mention "Model2"
development; a derivation of "MVC". Also, their are many frameworks
to choose from to assist your development. Regardless, it all boils
down to discipline and proper thinking. Think in layers and OO,
e.g. how can you separate the "model" (data), from the
"view" (display), from the "control" (logic); all comprise the
term MVC.
Alone, Java Server Pages (JSP) can be misused by incorporating
Java code as scriplets; doing everything from database connections
to business logic and application flow. A better approach would be
to only put HTML in JSPs and use Java tags to display dynamic data.
Your data would go in Java classes that follow the bean convention
with private fields and public getters and setters. Your
business and application logic would go in other classes; packaged
appropriately. While you're at it, you might as well look at
decoupling further by putting logic in a set of classes, creating
handlers that call DAO classes that handle database accesses, etc.
There are many ways to slice an application. I recommend looking
into the Apache Struts framework; It's well documented and would
be a good learning experience.
On top of all that, you still have many other areas to apply the
same principles: EJBs, RMI, etc.
--
Regards,
Anzime
|
| |
|
| |
 |
Martman

|
Posted: 12/4/2004 9:01:00 PM |
Top |
java-programmer >> jsp servlet code seperation confusion
Anzime wrote:
> Martman wrote:
>
>> I posted this on the .help NG but I believe you folks could probably
>> provide more of an accurate answer considering the help group is
>> targeted towards true beginners.
>>
>> Okay, where I am employeed I have the options of programming with
>> Microsoft Technologies and Java specifically J2EE. I have been
>> investigating the task of learning Java for about the last 3 to 4
>> months. I am a ASP.Net developer fulltime at work with C#. I was new
>> to OOP when I started into .Net about a year ago and am getting
>> better. However, our corporation uses Java as a National standard and
>> I am looking to advance some day and need to learn Java. Furthermore,
>> where I live, KY there are very few jobs for technologies other than
>> .Net and Java. No PHP or ColdFusion.
>>
>> In the last couple of years this code seperation theory has overloaded
>> the programming world. .Net does it with what's called code behind. In
>> my research of Java the only things I see that reference code
>> seperation is servlets (I am sure J2EE and EJB contribute also).
>> However, everything I have read on servlets reference outputing HTML
>> back to the browser via the HttpServletResponse and Request objects.
>>
>> My question, why in the world do they consider outputting HTML back to
>> a browser via a servlet considered code seperation. Furthermore, it
>> seems very time consuming and difficult to hand code complex layouts
>> in HTML and incorporate/format it for a servlet.
>>
>> Can someone please explain or direct me to a resource where I can
>> understand why using servlets at any point in an application would be
>> better than jsp or even applets? Sometimes it's hard enough to design
>> complex layouts with the assistance Dreamweaver for example.
>>
>> Thanks for any insight you can provide, I have read hundreds of pages
>> of information concerning this and trying to compare it with the my
>> current knowledge in the .Net world.
>>
>> Marty U.
>
>
> I haven't looked at .Net at all, so I everything I say is from
> a Java perspective.
>
> You wouldn't want to hard code HTML in a servlet; it's ugly, and
> difficult to maintain. Servlets are great for non-visual applications
> where you need HTTP support (request, response, etc).
>
> When you mention code separation I think you are talking about
> separting the "display code", "business logic", and "control logic".
> There are many tutorials on the web that mention "Model2"
> development; a derivation of "MVC". Also, their are many frameworks
> to choose from to assist your development. Regardless, it all boils
> down to discipline and proper thinking. Think in layers and OO,
> e.g. how can you separate the "model" (data), from the
> "view" (display), from the "control" (logic); all comprise the
> term MVC.
>
> Alone, Java Server Pages (JSP) can be misused by incorporating
> Java code as scriplets; doing everything from database connections
> to business logic and application flow. A better approach would be
> to only put HTML in JSPs and use Java tags to display dynamic data.
> Your data would go in Java classes that follow the bean convention
> with private fields and public getters and setters. Your
> business and application logic would go in other classes; packaged
> appropriately. While you're at it, you might as well look at
> decoupling further by putting logic in a set of classes, creating
> handlers that call DAO classes that handle database accesses, etc.
>
> There are many ways to slice an application. I recommend looking
> into the Apache Struts framework; It's well documented and would
> be a good learning experience.
>
> On top of all that, you still have many other areas to apply the
> same principles: EJBs, RMI, etc.
>
Hey thanks Anzime that really helps. You actually answered more than my
intentions with my poorly structured question. My main concern was to
seperate code from presentation and I just forgot to add the word
presentation to my question.
The good thing is you gave me a key bit of information that I needed to
help understand the code/presentation seperation concept.
Would you happen to have a link to a page that has a good info doc that
would help me understand using Java tags in jsp pages. I have searched
google but with the lack of knowledge I don't know if they are
explaining what you are referencing nor how well they are actually
explaining it.
Thanks again, big help
Marty U
|
| |
|
| |
 |
Ryan Stewart

|
Posted: 12/4/2004 9:07:00 PM |
Top |
java-programmer >> jsp servlet code seperation confusion
"Martman" <email***@***.com> wrote in message
news:zyisd.190557$HA.170068@attbi_s01...
[...]
> Would you happen to have a link to a page that has a good info doc that
> would help me understand using Java tags in jsp pages. I have searched
> google but with the lack of knowledge I don't know if they are explaining
> what you are referencing nor how well they are actually explaining it.
>
They're called custom tag libraries. Try here for starters:
http://java.sun.com/products/jsp/tutorial/TagLibrariesTOC.html
|
| |
|
| |
 |
Michael Borgwardt

|
Posted: 12/5/2004 2:17:00 AM |
Top |
java-programmer >> jsp servlet code seperation confusion
Martman wrote:
> In the last couple of years this code seperation theory has overloaded
> the programming world. .Net does it with what's called code behind. In
> my research of Java the only things I see that reference code seperation
> is servlets (I am sure J2EE and EJB contribute also). However,
> everything I have read on servlets reference outputing HTML back to the
> browser via the HttpServletResponse and Request objects.
Then your sources are bad or you misunderstood something. The idea is to
separate display-related code from the program logic and use JSPs for
(and *onyl* for) rendering HTML pages, while servlets and regular Java
classes handle the program logic.
|
| |
|
| |
 |
Heiner K?ker

|
Posted: 12/5/2004 3:41:00 AM |
Top |
java-programmer >> jsp servlet code seperation confusion
> The idea is to
> separate display-related code from the program logic and use JSPs for
> (and *onyl* for) rendering HTML pages, while servlets and regular Java
> classes handle the program logic.
Ack
--
Heiner Kuecker
Internet: http://www.heinerkuecker.de http://www.heiner-kuecker.de
JSP WorkFlow PageFlow Page Flow FlowControl Navigation: http://www.control-and-command.de
Expression Language Parser: http://www.heinerkuecker.de/Expression.html
|
| |
|
| |
 |
| |
|