aspose file tools*
The moose likes Servlets and the fly likes What, besides servlets and jsp, may be used for web-application? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "What, besides servlets and jsp, may be used for web-application?" Watch "What, besides servlets and jsp, may be used for web-application?" New topic
Author

What, besides servlets and jsp, may be used for web-application?

Ekaterina Galkina
Greenhorn

Joined: Sep 14, 2010
Posts: 15
I'm not sure that I chose the correct branch, and the question may be stupid, but I'll try to ask.
Imagine, that we have a web-application (which opens in browser).
Java is used on server side (we have an application server, for example Glassfish).

Question.
Does it mean that servlets (or jsp) are neceessarily used? Or is there another way to generate html pages? (The problem is that I've heard about many technologies, like ejb and others, but didn't use them).
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61432
    
  67

Any Java technology will be based upon Servlets and JSP (though some frameworks may provide their own alternative to JSP). EJB is not a replacement, but just another part of JEE.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ekaterina Galkina
Greenhorn

Joined: Sep 14, 2010
Posts: 15
thanks for your reply.
Bear Bibeault wrote:(though some frameworks may provide their own alternative to JSP). .

could you please tell which frameworks may provide their own alternative to jsp (for example)?
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
While Servlets are involved nearly all the time they may be hidden. Iif you use an action-based framework like e.g. Spring Web MVC you won't program servlets manually, you use the framework's own classes (e.g. Controller in case of Spring Web MVC). You still can decide what presentation layer you want to use. JSP is one possibility but it could be a totally different templating engine (e.g. Freemarker, Tiles, Velocity).

If you use the component-oriented framework like Wicket you use HTML and backing classes. You won't see any servlets there (while there still is a servlet or filter serving your requests, but framework managed).

When using GWT you will produce client-side JavaScript out of your Java code that can communicate to the server in different ways but typically all will be servlet powered (a custom GWT RPC servlet which eases developement or somethinglike REST which can faciliate servlets too, if Java based).

So Java (the ecosystem) allows a lot of choices and provides a lot of frameworks. Most (all?) of the web application frameworks use servlets internally, but you won't see them or use "raw" servlets mostly. JSP can be replaced much easier.
Ekaterina Galkina
Greenhorn

Joined: Sep 14, 2010
Posts: 15
thanks you, I'll look at these frameworks (especially Spring mvc) closer.

Now I'm puzzled, when ejb is needed.
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
EJB, Enterprise Java Beans, are part of JavaEE. They are (part of) a framework to build enterprise-y applications. These applications don't need to have a web frontend.

Servlets and JSP were intended as (one kind of) frontend for JavaEE application. But you can use these without the need for EJB in a container that does not know about EJB (a servlet container like Tomcat). In fact this allows for loose coupling between business layer and presentation layer and additional security. As EJB were not quite ... fun to program in earlier iterations, people built other application frameworks that could be used within a simple servlet container (frameworks like Spring). So you can have one without the other, mutually.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Hauke Ingmar Schmidt wrote:EJB, Enterprise Java Beans, are part of JavaEE. They are (part of) a framework to build enterprise-y applications. These applications don't need to have a web frontend.

Not true.
EJB are/can be used to execute the business logic in Java web applications (though you need an application server or an embedded EJB container inside the web container).
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
John Todd wrote:
Hauke Ingmar Schmidt wrote:EJB, Enterprise Java Beans, are part of JavaEE. They are (part of) a framework to build enterprise-y applications. These applications don't need to have a web frontend.

Not true.
EJB are used to execute the business logic in Java web applications (though you need an application server or an embedded EJB container inside the web container).


Hm. They can be used this way, but it is not the only way. EJB are not mere web adapter for business logic implemented by another system.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

What I was talking about is your sentence:
These applications don't need to have a web frontend

It is not true that enterprise application don't need to have a web front end.
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
John Todd wrote:What I was talking about is your sentence:
These applications don't need to have a web frontend

It is not true that enterprise application don't need to have a web front end.


Then maybe I just got caught in the subtleties of the English language and some false friends...

What I wanted to express is: These application may have a web frontend, but it is not mandatory. They can have different or multiple frontends as well. EJB are not bound to servlets/JSP, it is only one possibility.

(May, need, must, need, have... I need to do some vocabulary brush-up.)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42285
    
  64
John Todd wrote:What I was talking about is your sentence:
These applications don't need to have a web frontend

It is not true that enterprise application don't need to have a web front end.

Huh? There are plenty of enterprise apps that do not have a web front end. What are you talking about?


Ping & DNS - my free Android networking tools app
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Maybe we lost in words.
Hauke said:
These applications don't need to have a web frontend

This is generalization, some do need web front end and some don't.
Maybe it is a matter of miscommunication
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42285
    
  64
John Todd wrote:Maybe it is a matter of miscommunication

Indeed, I think so. In this context "don't need" means: they may have, but not necessarily so. In other words: some do, and some don't.
Ekaterina Galkina
Greenhorn

Joined: Sep 14, 2010
Posts: 15
thanks to you all.
Is it common to have web-based front-end and business logic on ejb?
In case if servlets are used separately (without ejb), who/what implements business logic? Does developer jus tcodes his own java classes (not using ejb) ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42285
    
  64
EJB isn't nearly as widely used as servlets/JSP. It's perfectly possible (and more common, I'd say) to create your own data layer based on JPA, JDBC or some other DB access library.
Harsha Ka
Ranch Hand

Joined: Mar 14, 2010
Posts: 45

If we are just using applications for simple things and not big enterprise applications I would say using EJBs would be overkill.You can encapsulate the business logic using POJOs and data model using JavaBeans But if you are using some complex stuff like JMS, web-services then EJBs save you a lot of work.


SCJP 1.6,Preparing (Tryin to prepare) for scwcd
Sidharth Pallai
Ranch Hand

Joined: Apr 21, 2008
Posts: 134

Thats appropriate, But EJB is nowadays a tiring job for any developer to code specifc segments of functionalities (Transactions/Security/Concurreny/JNDI Lookup) and at the same maintain better design approach. which is a cumbersome. So, todays trends provides Spring Framework, that comes up all-in-one plate to pick/use features which you need. Services are already in place , we just need to provide our implementations, and at the same mainatin design protocols like coupling throught DI/IOC , AOP , WebMVC, DAO integration with ORM , integration with struts/velocity/jsf... and lots more. !! Go through Spring Framework concepts , it will fetch you how to place ut problem state into designated places and make them feel/work in a better fashion , i mean in OOP's way!


Thanks & Regards
Sidharth Pallai
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42285
    
  64
Sidharth Pallai wrote:But EJB is nowadays a tiring job for any developer to code specifc segments of functionalities ... [snip] ... and lots more

This sounds a bit as if you may not have kept up-to-date with what's happened in JEE 5/JEE 6 - which introduced a lot of the concepts you're talking about to JEE, for example in the shape of JPA. There's nothing wrong, of course, with checking out Spring, but it's not as light-weight as it used to be, and JEE has gained considerably on it. Plus, some of its constituent pieces (like JPA) can be used in web apps without having to run a full JEE server.
Gabriel Emanuel Sosa Zimmerman
Greenhorn

Joined: Feb 12, 2011
Posts: 2
Sidharth Pallai wrote:Thats appropriate, But EJB is nowadays a tiring job for any developer to code specifc segments of functionalities (Transactions/Security/Concurreny/JNDI Lookup) and at the same maintain better design approach. which is a cumbersome. So, todays trends provides Spring Framework, that comes up all-in-one plate to pick/use features which you need. Services are already in place , we just need to provide our implementations, and at the same mainatin design protocols like coupling throught DI/IOC , AOP , WebMVC, DAO integration with ORM , integration with struts/velocity/jsf... and lots more. !! Go through Spring Framework concepts , it will fetch you how to place ut problem state into designated places and make them feel/work in a better fashion , i mean in OOP's way!


Wow! No disrespect but what century are you from man?. Spring is an awsome framework at least you got that one right. But Jave EE 6 has introduced some fantastic features and EJBs are now pojos. I hope this doesn't offend you as that is not my intention but I suggest you please read about the latest JAVA EE specification before making those claims as they are now entirely outdated.
Gabriel Emanuel Sosa Zimmerman
Greenhorn

Joined: Feb 12, 2011
Posts: 2
Ekaterina Galkina wrote:I'm not sure that I chose the correct branch, and the question may be stupid, but I'll try to ask.
Imagine, that we have a web-application (which opens in browser).
Java is used on server side (we have an application server, for example Glassfish).

Question.
Does it mean that servlets (or jsp) are neceessarily used? Or is there another way to generate html pages? (The problem is that I've heard about many technologies, like ejb and others, but didn't use them).


You may want to have a look at JSF 2. It's a great specification that builds on servlets but doesn't require you to write them yourself. It's somehow like jsp but with a rather different approach. It's a component based framework and uses facelets for templating. If you need a hand with this, just pm me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What, besides servlets and jsp, may be used for web-application?