Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: EJBs vs. Servlets ?!

Reply
Thread Tools

Re: EJBs vs. Servlets ?!

 
 
Razvan
Guest
Posts: n/a
 
      08-14-2004
> No, why do you think so? Servlets receive requests and sends a
> response back to the browser (usually). EJBs are often remote objects
> that expose methods to other Java classes. They are not used for the
> same thing at all.
>
> > The only reason I see to use servlets instead of EJBs is if do
> > not have an application server (like JBOSS).

>
> So, how does a browser call the EJB?


Thru a JSP, of course.
This is the reason for JSPs. They take requests from the
browser, send it to back-end (EJB) get a response and send it back to
the browser. Where the servlets fit in ?!! Having JSPs and EJB you
don't need servlets; this being the case, why use servlets at all ?
 
Reply With Quote
 
 
 
 
Tor Iver Wilhelmsen
Guest
Posts: n/a
 
      08-14-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (Razvan) writes:

> Thru a JSP, of course.


Funny guy! JSPs are converted into servlets, which are the components
the browser interacts with.

The advantages of using JSP over hand-coded servlets is that a JSP is
preferred if there is more output than logic, and the tag library
mechanism is a reasonable way of reusing code.

> Having JSPs and EJB you don't need servlets; this being the case,
> why use servlets at all ?


OK, try using JSPs without a servlet container.

(Other reasons for using servlets are the Front Controller pattern and
the Model 2 architecture, used by the very popular Struts web
application framework among others.)
 
Reply With Quote
 
 
 
 
William Brogden
Guest
Posts: n/a
 
      08-14-2004
On 14 Aug 2004 13:47:47 -0700, Razvan <(E-Mail Removed)> wrote:

>> No, why do you think so? Servlets receive requests and sends a
>> response back to the browser (usually). EJBs are often remote objects
>> that expose methods to other Java classes. They are not used for the
>> same thing at all.
>>
>> > The only reason I see to use servlets instead of EJBs is if do
>> > not have an application server (like JBOSS).

>>
>> So, how does a browser call the EJB?

>
> Thru a JSP, of course.
> This is the reason for JSPs. They take requests from the
> browser, send it to back-end (EJB) get a response and send it back to
> the browser. Where the servlets fit in ?!! Having JSPs and EJB you
> don't need servlets; this being the case, why use servlets at all ?


JSP are designed for createing character streams -> HTML pages
If you want to serve binary data you should use servlets.
Why not read about the many roles of servlets here:

http://java.sun.com/products/servlet/whitepaper.html

Bill
 
Reply With Quote
 
Jim Cochrane
Guest
Posts: n/a
 
      08-15-2004
In article <(E-Mail Removed) >, Razvan wrote:
>> No, why do you think so? Servlets receive requests and sends a
>> response back to the browser (usually). EJBs are often remote objects
>> that expose methods to other Java classes. They are not used for the
>> same thing at all.
>>
>> > The only reason I see to use servlets instead of EJBs is if do
>> > not have an application server (like JBOSS).

>>
>> So, how does a browser call the EJB?

>
> Thru a JSP, of course.
> This is the reason for JSPs. They take requests from the
> browser, send it to back-end (EJB) get a response and send it back to
> the browser. Where the servlets fit in ?!! Having JSPs and EJB you
> don't need servlets; this being the case, why use servlets at all ?


If you're using JSP, you're using servlets (because of the definition of
JSP). You may not be using them directly, but you're using them.

--
Jim Cochrane; (E-Mail Removed)
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
 
Reply With Quote
 
Razvan
Guest
Posts: n/a
 
      08-15-2004
> (E-Mail Removed) (Razvan) writes:
>
> > Thru a JSP, of course.

>
> Funny guy! JSPs are converted into servlets, which are the components
> the browser interacts with.


Indeed, funny. I am new to all this Java - related
technologies. After reading your anwser I realised that JSPs are just
Servlets. This is why there is a small delay when running a JSP for
the first time - the Java compiler must run first.

> The advantages of using JSP over hand-coded servlets is that a JSP is
> preferred if there is more output than logic, and the tag library
> mechanism is a reasonable way of reusing code.


When there is less business logic you should use JSPs;
however, when the business logic is complicated Servlets are better,
because all the formatting stuff is taking a small percentage of the
source file.
 
Reply With Quote
 
Razvan
Guest
Posts: n/a
 
      08-15-2004
"William Brogden" <(E-Mail Removed)> wrote in message news:<opscqx24gyk0yerx@ruby>...
> On 14 Aug 2004 13:47:47 -0700, Razvan <(E-Mail Removed)> wrote:
>
> >> No, why do you think so? Servlets receive requests and sends a
> >> response back to the browser (usually). EJBs are often remote objects
> >> that expose methods to other Java classes. They are not used for the
> >> same thing at all.
> >>
> >> > The only reason I see to use servlets instead of EJBs is if do
> >> > not have an application server (like JBOSS).
> >>
> >> So, how does a browser call the EJB?

> >
> > Thru a JSP, of course.
> > This is the reason for JSPs. They take requests from the
> > browser, send it to back-end (EJB) get a response and send it back to
> > the browser. Where the servlets fit in ?!! Having JSPs and EJB you
> > don't need servlets; this being the case, why use servlets at all ?

>
> JSP are designed for createing character streams -> HTML pages
> If you want to serve binary data you should use servlets.
> Why not read about the many roles of servlets here:


So, JSPs can serve only HTML while servlets can serve binary
also ! You are basically saying that you cannot serve binary data from
JSPs. Perhaphs you are trying to say that there is no point in doing
that. Since JSPs practically are servlets, that means they do not have
any limitations over servlets.
 
Reply With Quote
 
Tor Iver Wilhelmsen
Guest
Posts: n/a
 
      08-15-2004
(E-Mail Removed) (Razvan) writes:

> Indeed, funny. I am new to all this Java - related
> technologies. After reading your anwser I realised that JSPs are just
> Servlets. This is why there is a small delay when running a JSP for
> the first time - the Java compiler must run first.


Note that you can add <load-on-startup> to a servlet/JSP declaration
in web.xml to make it compile and instantiate it at startup, which
prevents the first access taking longer.
 
Reply With Quote
 
Christophe Vanfleteren
Guest
Posts: n/a
 
      08-15-2004
Tor Iver Wilhelmsen wrote:

> (E-Mail Removed) (Razvan) writes:
>
>> Indeed, funny. I am new to all this Java - related
>> technologies. After reading your anwser I realised that JSPs are just
>> Servlets. This is why there is a small delay when running a JSP for
>> the first time - the Java compiler must run first.

>
> Note that you can add <load-on-startup> to a servlet/JSP declaration
> in web.xml to make it compile and instantiate it at startup, which
> prevents the first access taking longer.


Yes, you are correct in the case of regular servlets, but the poster
explicitly mentioned JSPs, which you can not load on startup (unless you
precompile them).

--
Kind regards,
Christophe Vanfleteren
 
Reply With Quote
 
William Brogden
Guest
Posts: n/a
 
      08-15-2004
On 15 Aug 2004 07:01:10 -0700, Razvan <(E-Mail Removed)> wrote:

> "William Brogden" <(E-Mail Removed)> wrote in message
> news:<opscqx24gyk0yerx@ruby>...
>> On 14 Aug 2004 13:47:47 -0700, Razvan <(E-Mail Removed)> wrote:
>>
>> >> No, why do you think so? Servlets receive requests and sends a
>> >> response back to the browser (usually). EJBs are often remote objects
>> >> that expose methods to other Java classes. They are not used for the
>> >> same thing at all.
>> >>
>> >> > The only reason I see to use servlets instead of EJBs is if do
>> >> > not have an application server (like JBOSS).
>> >>
>> >> So, how does a browser call the EJB?
>> >
>> > Thru a JSP, of course.
>> > This is the reason for JSPs. They take requests from the
>> > browser, send it to back-end (EJB) get a response and send it back to
>> > the browser. Where the servlets fit in ?!! Having JSPs and EJB you
>> > don't need servlets; this being the case, why use servlets at all ?

>>
>> JSP are designed for createing character streams -> HTML pages
>> If you want to serve binary data you should use servlets.
>> Why not read about the many roles of servlets here:

>
> So, JSPs can serve only HTML while servlets can serve binary
> also ! You are basically saying that you cannot serve binary data from
> JSPs. Perhaphs you are trying to say that there is no point in doing
> that. Since JSPs practically are servlets, that means they do not have
> any limitations over servlets.


Whaaaa?
What I said was that JSP are designed to send character streams,
not binary data. Practically speaking JSP are limited to sending
character streams - ie "JSP have limitations over servlets."

Bill
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      08-16-2004
On 14 Aug 2004 13:47:47 -0700, Razvan wrote:

> Having JSPs and EJB you
> don't need servlets; this being the case, why use servlets at all ?


a) JSP's compile to servlets.
b) Servlets are written in Java, rather than
an accursed mixture of Java and HTML.

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java servlets: Hi All! I want to display xml file in browser using servlets datta.saru Software 0 05-15-2006 03:30 PM
Re: EJBs vs. Servlets ?! Will Hartung Java 0 08-16-2004 07:27 PM
EJBs as active components? Vjeran Marcinko Java 5 10-17-2003 08:01 PM
Beginners questions: Using EJBs on two Workstations bebonights Java 0 10-13-2003 02:28 PM
How widespread is the use of EJBs in app servers? Patrick May Java 3 08-19-2003 03:03 PM



Advertisments