in a student project we are currently developing a website which service is also accessibly via native Android and Windows Phone Apps.
The mobile apps access the service through a public RESTful API written in JAVA which is running on the same server as the website. The website is written in PHP and independent from the API, but they both use the same database (MySQL).
We wanted to extend the functionality of the API and allow registration for the service in the mobile apps.
The problem is that the user receives an email with a confirmation link as soon as he registers for the service.
What is the best approach to ensure that the emails sent by the API are identical to the ones sent by the website?
The easiest way we figured out doing this would be just using the same templates for both, website and API, but in that case we need to manually keep those templates in sync.
Is there a better way than the one above?
Templates need not be in flat file model in each environment. You can store it at one place but should be read by a common intra-web-api say local RPC.
I.e. Write a script in current website environment that returns either a template or duly filled in as the requirement case may be.
And the same API should be called from both web-site php scripts and from java API.
This process will not alter the output in both the environments. The output would always be the same when on a later date you change the template.
Related
I want to use firebase with Java web application using the full potential of java web like faces, Servlets
so lets say I want to register a user and the faclet will create an object of entered data and sends it to a servlet that will run some validation, then how can I add him to firebase from the servlet (Of course using JavaScript but how)?
You seem confused about the difference between Java and JavaScript. If you build a web app using Java on the server, you have two types of code that can run:
You have the Java code of your servlet, which run on the server.
You have JavaScript code, which runs in the user's browser.
If you need to access Firebase products from the servlet, you do so using the Firebase Admin SDK for Java. The documentation contains a section on creating a user from there.
If you need to access Firebase products from the browser, you do so using the Firebase Web SDK. The documentation for that also contains a section on creating a user.
There is no single right-or-wrong way to create a user. You will have to make up your mind where you want user creation to happen.
That said, since you're new to this, I recommend foregoing the Java server for a moment and first get started with just client-side Firebase. For a quick start, I recommend taking the Firebase codelab for web developers.
Our new start-up company is trying to build a mobile app with an accompanied website. We are trying to setup our application on Amazon Web Services.
We have Java code running in an EC2 instance, which will store data in S3. We want clients (iOS and Web for now) to communicate with the Java Backend via a REST API. Ideally the website would be hosted under the same AWS account.
The Java Code and REST API are already set up in a very basic form, but the setup of the Website is unclear, since this is new to us all. We also would like to evaluate beforehand if such a setup is even feasible.
Since I am in charge of the Website i have already spend hours researching this specific setup, but i simply lack experience in cloud/backend development to come to a conclusion.
Here are some questions we would like to answer:
Where would the HTML files and accompanied JavaScript etc. files be stored?
How can data (images etc.) that is stored within S3 by the JAVA code be accessed from the Website directly?
How could something like bootstrapping of data within HTML files be achieved (in JSON format preferably)?
How could the server be set up to compress certain files like CSS or JavaScript?
Please point me into the right direction, any comment is appreciated.
Where would the HTML files and accompanied JavaScript etc. files be
stored?
Either on the same AWS EC2 box or a different one, just give it a static IP and link that IP to the domain you want, done. Just remember to have port 80 open as a firewall rule.
How can data (images etc.) that is stored within S3 by the JAVA code
be accessed from the Website directly?
The files will have some url that you can link to directly in your html so it's essentially just a url.
How could something like bootstrapping of data within HTML files be
achieved (in JSON format preferably)?
You have a number of choices here. You could potentially create some JSP files to generate the HTML and load the JSP files on access and cache them so they load up super fast. You could argue however, this is overkill and in some ways, the REST endpoint should be robust enough to handle the requests.
Part of me thinks you should endeavor to use the REST API for this information so you just have to manage one endpoint, why make an extra endpoint or over engineered solution for the HTML that you then have to maintain? Build once and reuse.
How could the server be set up to compress certain files like CSS or
JavaScript?
During the build process, run the files through a minify process. This is built into maven so you could do it automatically or by hand using something like jscompress. This Minify plugin shows how to automatically minify your resources. Consider you'll need to be using Maven though as your build tool.
I'm planning a web application where users will be able to upload and process their files. The specifics of the application are irrelevant to my questions, but lets assume that the application will deal with mp3 audio files. I'm going to split my application in two distinct parts: the front-end and the back-end.
The front-end application will be a usual web application serving html pages to users. Typically a user will upload his file and fill an html form to specify which operations he would like to perform on the file. The files will be initially uploaded to a storage facility, such as Amazon S3, and later processed by a back-end server. I'm using Play 2.0.4 framework to develop the front-end application and this is going very well for me. I managed to implement user authorization, drafted most of the UI and also implemented file upload to S3. The application is currently deployed on Heroku without any problems.
For my back-end server I'm considering to use Play 2 framework once again. The back-end server will receive notification (http request) from the front-end server about creation of a new job. Job specification will include a link to the original user file in the storage and arguments describing the job. The job should be added to a queue. Now the most important part is to delegate the actual processing job to a third party program, which most certainly will be a compiled command line utility, such as SoX for the case of audio processing, written by good people using a programming language of their choice. As far as I know it is possible to call an external program from java, pass command line arguments and collect the result. After processing is done, the back-end server will upload processed file back to storage, and send notification (http request) to the front-end application, which will store a link to the processed file and display it to the user at some later time. To be able to use command line utility I'm going to deploy the back-end application to a Amazon EC2 instance with a Typesafe stack installation.
Here are some questions about this basic plan:
Is Play 2 a reasonable choice for the back-end, or should I look into alternatives? One of them seems to be CGI, which according to Wikipedia "is a standard method for web server software to delegate the generation of web content to executable files." Unfortunately I don't have any experience with that.
There shouldn't be any problem implementing a job queue with Play?
Is it possible to install a command line utility on EC2 and call it from Play?
Should I expect any problems installing Typesafe stack on the EC2? This post briefly describes what I'm planning to do https://www.assembla.com/spaces/bufferine/wiki/Typesafe_stack_on_Amazon_EC2
Assuming that in the future the application will grow, how would I split the jobs among multiple instances on EC2? Should I create a separate job-balancing application in between my front-end and back-end?
I would appreciate any advice! Thanks!
Note: I'm using Java api for Play 2 framework, since I'm not familiar with Scala language.
You may consider Akka for processing and it's built in Play2. It will help you to manage tasks easily, and even saving hardware ressources if used with advanced features. There is a Java API that should cover all your needs. And it's not necessary in a backend APP, if you need more power you can scale even better with two same instancies. Play and Akka are stateless, you can just add new instances to scale. To make it run on EC2, just use the play dist command.
And yes, you can install whatever you want in EC2 and call it from your app.
You may like:
http://akka.io/
http://www.playframework.com/documentation/2.1.0/JavaAkka
http://www.playframework.com/documentation/2.1.0/ProductionDist
also, but in scala
http://blog.greweb.fr/2013/01/playcli-play-iteratees-unix-pipe/
http://blog.greweb.fr/2012/11/play-framework-enumerator-outputstream/
I want to create little Java application which can interact with secured website.
We have Railway site (https://irctc.co.in)
I want to create a console application from which I can send the usename and password to site as web post method and the result can be converted into console format.
Instead of opening the site in web browser, i would like to make it simpler using console window by avoiding other web elements and ads etc..
is it possible to do in Java? Please guide me.
I see two ways to do that. The first one is to implement java app based on top of HTTP request-respond engine. In this way you do not have to make any changes in your web-site but processing HTTP responds could be complicated due to design features. The second one is to create simple front-end service on Rails for special cases and interact with in your console app. For message format you can use JSON for example. This way IMHO is more suitable. Both way suggests use of HTTP libs stack, Apache has it there http://projects.apache.org/projects/commons_httpclient.html
I need to develop an application with following features and want to
understand if GWT can be used to develop this application or is it the
right technology to use ?
1) Backend is in Java and uses MySQL
2) Desktop based UI to create some datafiles and data will be stored
in MySQL DB. This app will generate the data.
3) A desktop based application using which users can get access to
that database on a CD. This app will provide access to data locally
stored on a CD.
4) A web interface using which users can get access to the database
remotely. This app will provide remote access to data.
For local access also, we have the flexibility to install and run the
web server.
Should I use GWT for the UI part or should I use some thing else ? I
would like to provide common UI, look & feel for local and remote
access to data.
Please advice.
Thanks,
Deep
As you can run the web server also locally, I don't see a problem to re-use the same GWT app for both use cases.
It would be harder if your users must communicate with both the remote and local server from the same browser window/tab, at the same time. That can only be done with JSONP, which is possible with GWT, but it's not as nice as GWTRPC.