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.
Related
I have recently started to learn Java and I have a created my first desktop application using Swing. I now however, want to start my own little project that involves creating a desktop application that can retrieve and input data on a webpage.
Ideally, I would want to input and retrieve data from a webpage that is open and visible in a web browser (preferably Chrome), rather than doing it all behind the scenes where it cant be seen. I need my program to have a GUI written in Swing, which takes values and then inputs them onto the webpage; I need to be able to take values from the open webpage as well as be able to press buttons - all through my desktop app.
In conclusion you can say I need to create an application that automates a web browser, however it needs to be able to do it to an already open browser/webpage. What should I do and use to achieve this?
You can achieve this by applet programming in Java which can send request data to server web page. Additional to this you can use Web Service mechanism to where you can get data from your swing form and bind the request in any appropriate transfer method like XML or Json and you can post it on to server endpoint. For example in JAVA you can use Jersey rest implementation for this.
What is the best way to have a SQL database that can both be accessed by an android device via java code and by a web app via php code?
In my mind I imagined a MySQL database somewhere on the cloud that is accessed in all the normal ways by the web app using mysqli_connect and then somehow the same database calls are made in Java inside the android app.
But after some research it appears this may not be the way to do it. What is the way to do this correctly?
EDIT: It was suggested my question was too broad. What I want then is a database of some basic financial information which is stored on the cloud which is then able to be accessed via a web app written in the LAMP stack and via an android app (with java code).
It is a really simple problem but I am not sure what the best practice for such a problem is in android (I come from a web dev background)
The standard way to access a database for mobile application is different than a normal web page/application.
Mobile devices should never run queries in the database; What you do is create a web service that does all the queries in the database and then sends back HTTP responses in xml, JSON format to the mobile device for consumption.
At the same time you can create a web client that interacts with the web service the same way your mobile app does. This way if you get erroneous data you can debug the web service without having to recompile the code in the mobile app.
Do a Google search for restful web service
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.
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'm using the Java Preferences API to store and retrieve small pieces of information in a swing/java application.
Now i have setup Java Web start to launch the application from my web page, and I get a security exception. In order to get rid of this exception, I'd have to prompt the user for permissions. And I refuse to do that because my application does nothing else that would require the user's permission.
That's why I need an alternative solution for storing a few key values from one execution to another. Some sort of cookie or whatever. Do you know any please ?
You may want to look into using PersistenceService, a feature of Java Web Start that "provides methods for storing data locally on the client system, even for applications that are running in the restricted execution environment." Related examples may be found here and here.