0

I have an application currently running based on servlets (app server glassfish). External applications make an HTTP call to that servlet and get response once successfully achieved what its designed for.

I need now to shift the whole application to JSF2.0 as it needs a front end and sticking to servlet/jsp is not an option.

My questions are:

  1. What's the recommended way to achieve the scenario of external applications getting things done through http calls in my JSF2.0 web app (that is currently I am achieving with servlets)
  2. I need to maintain some counters in Application scope; Would you advise me to keep using servlets in my jsf app too and are the application scoped beans callable in servlets?
kolossus
  • 20,559
  • 3
  • 52
  • 104
khawarizmi
  • 593
  • 5
  • 19

2 Answers2

0

The way how you described the old application sounds much like a web service.

JSF is a component based MVC framework, not a web service framework. So JSF is basically the wrong tool for the job. If you want to continue with the standard Java EE stack, look at JAX-WS (SOAP) or JAX-RS (RESTful) instead. The latter is "the" standard web service framework these days.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks for the pointer to RESTful webservices. I believe webservice alone may serve what my app is doing currently - JSF would be the website interactions for clients for reports/management etc. I believe both of things (RESTful and JSF2.0) may be within single enterprise app, is this right? – khawarizmi Oct 07 '12 at 12:06
  • JSF is basically a MVC framework for HTML form based applications. So if there is no means of HTML forms, then JSF is out of the question. – BalusC Oct 07 '12 at 13:42
0

What's the recommended way to achieve the scenario of external applications getting things done through http calls in my JSF2.0 web app (that is currently I am achieving with servlets)

Like BalusC said, JSF is not exactly what you need and is not designed for what you intend to use it for, webservices are. That being said, you could achieve your goals using JSF if developing an effective web service is not in the cards for you ,either because of a lack of technical expertise on your team or the time factor or other technical constraints require you to serve your customers via a webapp (I honestly can't think of any but hey, you never know)

That being said, I'm assuming you already know your way around JSF2: take a look at this answer to a question somewhat similar to yours. Ultimately, since you're in the Java EE 5-6 stack, I'd strongly suggest you begin work on developing webservices (for basic requirements,they're fairly straightforward to develop). You can download a tutorial here or use oracle's tutorial

I need to maintain some counters in Application scope; Would you advise me to keep using servlets in my jsf app too and are the application scoped beans callable in servlets?

Unless you give us your specific use case, there are very few and far between reasons maintain a servlet within a JSF app. Yes, application,session and request scoped beans are accessible from within a servlet. They're simply stored as objects within the scopes they're named for, application scoped beans within the applicationScope, session scoped beans within the session and request scoped beans within the request. You may use your JSF webapp to serve low level http requests, but it's a square peg in a round hole chief.

Community
  • 1
  • 1
kolossus
  • 20,559
  • 3
  • 52
  • 104
  • Thanks alot - it really helped. Sticking to servlet had only reason of our clients connected on legacy interface with just a traditional 3 steps call to our servlet; (1)create url/urlconnection (2)read url call response thru bufferedreader (3)store the response. SOAP Ws was a big challenge for clients. – khawarizmi Oct 07 '12 at 12:27