Styling Java with HTML/CSS [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
So im fairly new to Java, anyway i have a implemented a simple Java program on IntelliJ which runs in the IntelliJ terminal, it basically ask the user to input some details and then records them along with the current time.
I now want to style it out using HTML/CSS to convert it into a webpage, where the user would enter the details into input boxes etc.
Im not sure how to approach this, what would be my best shot?
Also the user input is also being stored in a variable at the moment, would i have to use a database instead for a webpage?
Thanks.

Well I would recommend you to read first about what is Model-View-Controller paradigm in web page architecture, then you can probably better reply to yourself in terms of what you need for your webpage in order to do what you want.
I will grasp some about the things that you need:
You will need a database to store your user input details along with with the current time. (MySQL for example)
After that you need to define which type of data you need to save, you will have to make models in java for parsing those details from java to the db and vice versa.
Then you will need to create some services (You can learn about repositories before services if you need, which you probably would) to support those connections with the database in which you will retrieve data from DB.
A way to control how those services to serve your webpage is having a controller for processing the HTTP requests.
Last but not least, the controller will "glue" your jsp views with the data from services to be shown in your browser.
There will be many other ways, at least this is the way I know. I use Spring framework for building the MVC.

You have to do full stack page with java backend and html & css for the front-end.
Do a webservice with spring boot this generate a restful API to communicate with your web page using HTTP methods ( Get, Post, Put and delete ) and use AngularJS for example to parse the webservice created.
check out this : example

Quite simply, you'll need a web server to spit out HTML. I mean, there's lots of ways you could do it, but far and away the most popular is a web server.
There are lots of options for you. As an Eclipse fanboy myself, I can't say specifically, but a cursory google search yields this Tomcat plugin which should allow you to run a web server via IntelliJ. There are probably dozens of other plugins for differnt web servers you could use.
What you put into that server is up to you - it could be a simple html document populated by parameters, a REST endpoint, a JSP, who knows what. That's beyond the scope of the question - the first step is getting your web server up and running and then deciding the framework to use.

Related

Connecting and fetching data from mysql using angularjs [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am new to angularjs , can anybody guide me in performing CRUD operations in MYSQL and display in html form using angularjs... to be more precise... I want to store information to customer details such has name,consumer number,contact,address and update the same whenever necessary using java..
Hello and welcome to SO,
I created this diagram in order to make you feel more comfortable with the subject.
As you may see I didn't mention any language: Client, Server nor Database, because the language itself has nothing to do with REST APIs.
Instructions - begginer:
(If you are using PHP, I'd recommend SlimFramework, which is the light, scale, easy to start with, PHP Framework).
1) Pick a server-side language.
2) Create a Database Resource.
3) Pick a Server Side Language.
4) Create 4 Scripts that each does one of each:
Create,Read,Update,Delete.
5) Connect endpoints with each of the scripts, URL -
GET,POST,DELETE,UPDATE.
6) Verify that you can access each of them from the web (authenticated
or not).
7) After you verified that endpoints are working, time to connect
Angular:
7a) First try to create buttons for each action, and link it with
$http.get, $http.post, $http.delete, $http.put actions.
7b) Once it's working you might wanna step up and use ng-resource or
restangular.
P.S: I didn't supply much code information since once you understand what I stated on top, you'd realize that writing code for that isn't really hard.
After you complete these ,
You might wanna start with: Server side and Client side authentication, Performance, Multiple resources and collections, CORS and preflighted requests, and so on.
Good Luck.

Android App with Online Database [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i'm creating an app wherein the database are uploaded online without website, the concept of the app is like Waze app. I dont know where to start im asking for ideas and help. do i need to create a web server?how?i will mark this correct for those who can answer thanks.
This is not a simple task because it relies on many parts doing its proper job... In order to do what you want to do you need basically 5 things:
1.- Server: which will feed live information to the app.(There is a ton of servers that can be used to get this part done. If you are used to, or willing to learn php, I suggest you to start researching XAMPP (it uses Apache server running php stuff) [https://www.apachefriends.org/es/index.html]).
2.- Database: Most likely the server will need to work with information stored in some place. databases are perfect for just that. XAMPP also comes with MySQL which happens to be the most popular open source database out there.
3.- Format :You need to determine how the information will be passed from the server to the mobile device. The most common ways are: JSON which is plain text, XML that also is plain text but formatted diferently. this is important because you have to send the information from the server using this format and also your mobile devices will need to interpret the information in this format.
4.- Choose a way to send and recive the information : i would suggest Http/Ip protocol for this, as it is very common. Investigate Http requests and responses.
5.- Your device must be listening (or asking) for the content : the device will have to implement some sort of timer to ask the server for new information. This is determined by the logic and prupose of what you wish to do.
do i need to create a web server?
Yes! You need to create a web server, then, a webservice (database query etc...) which communicate between your application and your webserver. I think that all!

How to use Java in PHP? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I want to use WordPress for my web development, which is PHP written, including the database connection to MySql. The whole thing is PHP. But I need to use Java to back-end data processing and a number of existing Java open source libraries.
A google search shows that PHP/Java Bridge is a way to go. Is that bridge best way to go? If everything is PHP with WordPress, is still a way to use J2EE technologies, inlcuding JSP, Servelet, etc?
edit
Java is needed becaue I need to run machine learning algorithms, libraries for which are only available for Java. Also, PHP may run into efficiency issues when it's used to process large amount of data.
A good example of libraries in Java I am going to use is those processing Big Data, which are mainly Java, like Hadoop.
The very simple answer here is don't
PHP is designed to, at every page request start up, execute a small series of scripts as a single operation, output the data associated with those scripts and then immediately die after generating the output. It literally does not have time to wait for your Java programs and libraries to do their thing, so don't try to put one in the other, which is why PHP scripts that rely on databases tend to have heavily optimised databases for immediate retrieval, instead of general databases that rely on joins and selects that take a few seconds to form the correct data response. Neither PHP or users browsing websites have time for that.
What you could do is wrap your java tools in Java Servlets and have them running on the same server/host that your PHP instance is running from, so that your scripts can access the Servlets as http://127.0.0.1:7254/... as it would any other restful API it needs to use while generating your script output, as long as you make damn sure that you're not going to make PHP wait: if it has to send data to your tools, that is a post-and-forget operation, PHP should not be getting any response back other than an immediate "data accepted" or "data rejected" before the data is then actually handled by your tools. If you need to post data and then get a result back, you're going to have to use two calls. One to post the data, and then a second call to request the result of that posting.
For instance:
web page generation chain: WordPress CMS based on PHP -> your database
web input for processing: WordPress CMS based on PHP -> Java Servlets for machine learning
data processing chain: Java Servlets for machine learning -> your database
So you build pages only based on what's in your data base, you post data to your java Servlets only to get them to start doing something and you don't wait for a response, their result will end up in your database and you'll get it for pages once it's in, and your java programs do what they need to do independently of your WordPress setup.
And if you're going to do that, you should probably write that functionality as a WordPress plugin that can talk to your Java Servlets.
And now you have a second project you need to work on: turning your java programs into web servers. Not terribly complex, but definitely something you're going to lose some time on doing right (because you'll need to wrap with servlets, as well as make sure you can have those running without crashing on the same server as your wordpress instance, which is always fun)

How to build a comprehensive website that has many components with play 2 with Java [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have many websites build with Liferay. The reason I used Liferay or portlet based framework is that the nature of the websites. Usually, each page page display multiple content coming from different providers using rest web services. For example, the home page will display news coming from new provider, videos coming from other provider, and music coming from another provider, and so on, I guess you got the idea. I usually design a portlet for each content provider and reuse them as needed. Now coming to my question, I would like to use play 2 with Java to build such websites and from what I have understood so far is that I need to have a model that contains all of these data and send it to my template to be rendered. For example, /index will send the request to the controller.index() and then I have to populate a model that includes all the data: news, videos, and music, then return OK(template(model)) to send the model to the template to be rendered. The problems I see with this way is that The model will be huge which includes all kinds of data structure, and since content retrieval is different from one content type to the other it will make the code very complex and I can kiss reusalbilty goodbye.
Perhaps there is another way to build this, or maybe I didn't understand Play very well and Play is not suitable for this kind of websites. I think I'm not the first one who faced this before and I will appreciate your kind help. Please note that I'm not looking to start a debate on X vs Y, I just want to understand how to use play to build a website with rich content.
Thanks,
Iyad
Play is suitable for this kind of job as much as any other web-framework, anyway first you need to get some general experience on it and next... project your application i.e. with some diagram tool, finally you can start coding.
The way how will you design your model(s) depends on you, personally I'd create a separate model for each data type - then collect them in one data model (not persisted) to pass it easily to the view, anyway that's just a tip of iceberg.

Simplest way to make java crud app [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am trying study web development using Java but its seems very intimidating. all the tutorials are showing very complex methods, even the sample applications that came with NetBeans. I have some experience working with PHP but none with java.
Is there any simple way to use java on the server to just accept post requests and save to database and then display data from database without using things like javaServer faces?
Is it necessary to use frameworks like spring?
Pls forgive if i am asking stupid questions. i cant seem to find where to start learning from and tutorials seem too confusing.
Links to any good article will be very helpful
Thanks
For this purpose you should be familiar with the Servlet API, and preferably also with MVC frameworks and so on.
For the whole world to be a bit more straightforward for you and to steer away from the average-PHP-community-drawbacks (e.g. nobody tells you how to code well), I'd recommend to read THIS book.
But first of all, start HERE and then move on to THIS SITE.
The other way around (talking about DB access, not the web service here) is using raw SQL via JDBC which I won't recommend unless you have a good reason for it and you're already familiar with using a DB the right way (mysql and mysqli libs of PHP won't necessarily drive you the right path; PDO most probably will however).
Of course you don't necessarily need to use frameworks, but you're (actually in any language) way better off using them. Yes, probably the closest thing to the "nobrainers-php-methodology" (mindless coding; wiring UI, DB access and business logic together in a single file; etc.) is using the Servlet API, and then through a java.sql.Connection send your GET/POST data directly to the DB via JDBC. But doing so is slightly worse than cruelly murdering cute little squirrels/bunnies/kitties/insert_your_favourite_cute_creature_here
You'll also need a servlet container, most common of which is Apache Tomcat.
To learn Web Developing with Java Play Framework 1 is very nice:
Step by Step guide for a cool blog: http://www.playframework.com/documentation/1.2.7/guide1
Documentation: http://www.playframework.com/documentation/1.2.7/home
CRUD module documentation: http://www.playframework.com/documentation/1.2.7/crud
You get compile feedback directly in the browser.
Run your tests in the browser.
No redeployment to containers necessary/hot deployment.
No servlets.
Play 2 is already around, but going through Play 1 is much simpler if you are new a the Java world.

Categories

Resources