Should I make a Web Service with REST - java

I have made a web application that administrate questions for a quiz. The web content is divided into two pieces; One administrating part, and one public part. These interfaces are made for desktop web browsers.
Now, I want mobile devices to be able to browse these questions (with the look and feel of an application).
So I thought of two ways I could do it; Just add another folder in the webcontent named mobile make a custom interface for mobile phones and just add a webview with that URL in Android/iOS etc.
Or, make a Web Service using REST and make a new web application that is interdependent of the question project and act just as a client of it using the REST services.
Does one of the approaches above seem reasonable, or are there other better ways of doing it?
Update
This is a project made with EJB and JSF. Should I just add a folder in the JSF project and point mobile phones to that?

This is typical MVC application where you need to have two type of views
HTMl view for your browser based clients
XML view for Mobile applications (achievable by REST as you mentioned).
I would suggest to have a native mobile application which would talk to the web server via REST APIs.
Not sure which framework you are using here but most of the MVC framework will allow you to create XML views (Please check struts2 rest plugin)
Now the overall idea/design should be :
The web controllers/Actions talk to delegates
The delegates in turn talk to DAOs
DAOs talk to Database.
You will have different controllers for different end users (html for browsers/xml mobile)

Check out ft.com on your iPad, may be Android powered tablet might work as well. I believe this website will demonstrate the richness of HTML5/CSS3 based application.
On the other side there are certain advantages of making native applications but the problem is that you will have to create your app multiple times for different kind of platforms.
There is one solution to the problem above, you can use something similar to Appcelerator Titanium where you will do your coding in Javascirpt and their cross compiler will create native apps for you, if nothing, it's worth looking at once.

Related

What are necessary components and strategies for developing a REST-based client program?

I have been doing research for days and am so lost because everyone implements this differently or these tutorials are unclear.
I will be writing a web application that uses API's from sites like AWS, CROWD, etc. to create a single-sign on portal to manage many different things.
I have never worked in web development before, so this is all new. How should I get started in this project? What exact files will I need to create? Any advice would be helpful.
The only constraints that I have been given is that this will run in Tomcat, so I need to use java.
You need to understand the basics of client - server architecture and develop a
web service to standardize the REST based actions such as RPC.

Java App with Swing and Web GUI

I need to build a desktop application for internal users for certain business. It also needs web based GUI for external users. I know, with web GUI both internal and external users can access it, but there are certain factors which are outside our control - due to which, desktop application is really unavoidable. For the purpose of this question, I would like to focus on the way to support both Desktop client (Swing) and Browser client.
Are there any best practices to be followed? I could think of below:
Expose service classes as web services and use these from both Swing client and web client
Expose service classes as EJB (business is into Java EE techs) and use Swing client as EJB client. Web client can use controller classes to interact with EJB
Are there any known benefits of using either approach, apart from technology agnosticism offered by web services?
Also, for swing client, I am thinking of using Java Web Start for easy distribution. I have never used it before, but from what I understood, it can support automatic version check at startup and update the client when required - is this correct?
If you need to avoid dependency to Java/JVM on the browser (which you most likely at least want to), you should definitely go with mixed Swing-Vaadin approach. Build the internal application with Swing or JavaFX and web part with Vaadin. The programming model in Vaadin is so close to typical desktop UI library that it is really easy for the same developers to work with both code base, and naturally you'll use exactly the same backend.
See the example application I recently built to demonstrate a setup like this.

Exposing only certain part of the web application over internet

I have a j2ee web application that is typically accessed over the intranet.
I have a requirement to have only a small set of webpages in the application exposed over the internet. There isn't a large set of users who need the internet access. I dont really want to expose the whole application as is over the internet, since it has some other sensitive data. I'd like to add an extra layer of access restriction/security on top (even though the application has role based access). What would be a good way to achieve that?
Some options that come to mind are below (not given too much thought to it yet)
Figure out something in Apache (our web server) to restrict access to only certain set of URLs in the application. Not sure if something like that is supported out of the box or with some modules.
Mark internet based request with some attribute in Apache, and in the application layer use Spring security to restrict access.
Use something like a citrix server to allow indirect access to the application through a virtual desktop. I wonder if this is easier said than done and if its really buying me anything.
Build another web application that acts as a proxy to my large application for those limited web pages. Initial thought, this sounds like too much work.
Your thoughts? Any Better options, different products?
I would recommend to use Spring MVC.
As you already have role based access in your application, it should be quite easy to develop controllers which will render jsp that are relevant to that logged in user.
Though Spring MVC being a proven and robust framework, compare the effort that you need put in for Spring MVC integration with other solutions.

Java Backend/Server design setup

This is a very beginner question. I have tried to search for advice but am overwhelmed by the amount of information and would like some help with ideas on approaches to server design or what to search for!
What I would like to set up is a backend server that provides search capabilities and business logic and validation across some fairly basic data. It wont get too large.
I would then like to be able to plug in a website as a front end or a mobile app or a facebook app or even a desktop app..
My question is what is the best way for front ends to hook into the backend? I would like to have various user accounts with permission levels so authorisation would be important.
I generally only code as a hobby so whilst technically I have built a spring based website before the exact semantics of the client server relationship weren't clear to me. Now I want to separate the backend so that is is agnostic of how the data is displayed or entered completely and can run on a separate machine.
Thanks,
Rob
There is a ton on options. I had good expirience with apache CXF rest services (logic encapsulated in java beans, spring configuration) and pico web remoting ( more exotic,
but also rest service and plain java objects providing business logic)
if you ar already using spring, I would recommend to stick with CXF - it integtrates seamlesly ( and is spring configured itself )

Multiple web apps deployed on separate tomcat server with a single access homepage?

Well, I looked and searched but didn't find what I was looking for exactly, so here it goes.
We have multiple web apps, each deployed as .war on a separate tomcat server. We're planning on creating a portal like common access page for all the apps, where users can go and select the app while the navigation menu and layout will stay the same for this common homepage. This common access point/portal will also be an app of its own.
I am curious and have been scratching my head for a while, what's the best way to approach it? The reason for deploying each app/server isolated with one another is to increase up time in case of some issue in another app.
My question is, can it be done without using portal technology? Are there any good books that discuss thes architecture/deployment strategies?
I'd appreciate any pointers.
An old fashioned way to do it would be to keep a top frame from your menu app, and use the lower portion for the other apps, but it's not recommended.
Apache tiles lets you integrate page fragments, like the top menu, which you could synchronize to various servers with a rsync script.
Another possibility, would be to ask the fragment from the central server using an AJAX call with JSONP, to overcome the cross domain limit.
I suspect that since the apps are already developed it's too late for this fourth possibility, but the cleanest way to develop an app now, is writing a platform API, accessible with AJAX calls.
To clarify:
Apart from integrating the layout, do you also want to have a common login?
Why do you reject portal technology?

Categories

Resources