When is java used in a Dynamic Web Project? [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 8 years ago.
Improve this question
I loved the diversity of java ever since my first time using it. With that said I have tried to use it to its fullest. I am in the development of a computer game, android game, and website. Yay me. My problem is that I've been learning html, css, and a little bit of javascript for use in an eclipse dynamic web project. I don't see where or how java plays into the equation. To summarize I am asking for an explanation of where java would be used inside of a dynamic web project and maybe an example.
What I have now: http://192.168.43.194:8080/Pointlight_Productions/homepage.html

Dynamic web project is an Eclipse term, as far I know. When you create a Dynamic Web Project, you're typically telling Eclipse to manage your project as if it were intended as a web application to be deployed on a Servlet container. Eclipse will compile your source and resources and produce a .war file that you deploy in a Servlet container (Tomcat, Glassfish, etc.)
A Servlet container is written in Java. But this is provided. You write Java server code. In other words, you implement a number of Servlet classes that handle requests and generate responses.
For example, you might want to show a customized page for a user in an HTTP web application. Your Servlet would receive an HTTP request containing the name of the user. Your Servlet (or the services it depends on) would look up the name in some database, retrieve all the information for the corresponding user, and generate an HTTP response, possibly HTML, that would display that information.
Reading:
Our Servlet wiki page
How do servlets work? Instantiation, sessions, shared variables and multithreading
Java EE 7 Tutorials

Related

Styling Java with HTML/CSS [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 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.

How to use PHP/HTML as interface and Java/Python as function in background? [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 6 years ago.
Improve this question
I'm thinking about writing a desktop application that the GUI is made with either HTML or PHP, but the functions are run by a separate Java or python code, is there any heads up that I can look into?
There are a couple of possible options:
Run your backend code as an embedded HTTP-server (like Jetty* for Java or Tornado* for Python). If the user starts the application, the backend runs the server and automatically starts the web browser with the URL of your server. This, however, may cause problems with the operating system firewall (running a server on the local machine)
You could also have a look at CEF (chromium embedded framework). It is made for exactly this purpose (running an HTML-Application inside your code). It uses the same codebase as the chromium (and chrome) web browser. It was developed originally for C++, but there is also a Java binding: java-cef
Oh and by the way, PHP is a server-side language. I would not recommend to use it in your scenario (since your backend code is Python or Java).
*I have not enough reputation to add more than two links, so you'll have to google those ones yourself.
You could expose data from Java or Python as JSON via GET request and use PHP to access it. There are multiple libraries for each of these languages both for writing and reading JSON. GET request can take parameters if needed.

How to add java code into a Static web page? [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 want to create a static web page (same content to all clients).
In the meantime, I want to run the site as follows:
- Double click on the html file. (So if I'm not wrong, I don't need server side, i.e apache tomcat).
(I want this for now, in order to make progress in logic)
The static web page will contains:
browse button
OK button
(by 1&2) when the user choose a file and click OK I want to open a tcp connection to a remote appliation and exchange some data.
Several Q's:
How can I use java code (to send/recive messages) in HTML files (after the user click on "OK") ?
Do I need to use JSP & TOMCAT ?
(I want somthing that will be use for my interest only, and will not be as a internet web page)
If you reliably want to run code on a web page without interacting with the web server to do so, you need to use a language native to the browser.
As of 2015 that would be Javascript (which is a very different language than Java).
Interacting with the web server is then typically done with AJAX calls, where the part of your code running inside the browser exchange data with the part of your code running inside the web server. The front end code is again typically written in Javascript and the backend code in whatever the web server supports.
Note that after you have done some initial experiments, most likely will need a framework to make this easier to do for non-trivial behaviour.
#1: I am not sure what you are heading for, but Google Web Toolkit could help. Basically it splits your application in a client and server part, all written in java, but the client part gets compiled to javascript. This way you can develop all in java and bootstrap it within ANY html page.
#2: Easiest way would be to write the server in java and host its war-file with a jenkins. But there are much more possibilities including a non java server.

UI recommendation in Netbeans for a Maven web application [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've always been a backend C/C++ developer. Working on a Java project (Netbeans), and I am trying to figure out how to do the front-end/UI. While I am a pretty good back-end dev, I haven't really been keeping up with the latest and greatest in frameworks, etc. for the front-end.
The Java back-end component can communicate with JSON over websockets. I am trying to figure out what front-end framework I should use. I also don't want to recreate my project, and would just like to add to my current Maven web application project.
So what's the verdict? What's hip and cool these days? HTML5? JQueryUI? (are they even mutually exclusive?)
Should also mention that I just want to make a quick UI, b/c I am planning on handing off the task to another programmer for a "proper" front-end component later on. At the same time, I do want my version to be "decent". So, in a nutshell, I want something that is easy to use, but still capable.
Thanks!
Assuming this a web app, Angular is getting popular and Bootstrap has been popular for a while. Use pre-built templates you can find for free or at a site like http://themeforest.net . Don't waste your time trying to code your own, unless its super simple.
You probably want to also think about how the backend will communicate with the front if you haven't already. For example, will it use Servlets, or a framework like Spring Roo? You can also build the front in a completely different language, like PHP, as PHP outsourcing is cheaper and easier to find than Java . PHP is a server side language like Java, but I'm talking about a situation where the website's backend communicates with the java backend via an API or sharing a DB. PHP has many MVC frameworks such as Symfony and Laravel.

Difference between Applet and Servlet and their usages [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
What is the difference between an Applet and a Servlet and what are a few examples on how each of them are used? I am new to networking am I am wondering how these things are different.
From Wikipedia: A Java applet is a small application which is written in Java and delivered to users in the form of bytecode. The user launches the Java applet from a web page, and the applet is then executed within a Java Virtual Machine (JVM) in a process separate from the web browser itself. Applets are used to provide interactive features to web applications that cannot be provided by HTML alone. They can capture mouse input and also have controls like buttons or check boxes. In response to user actions, an applet can change the provided graphic content. This makes applets well-suited for demonstration, visualization, and teaching.
A servlet is a Java programming language class used to extend the capabilities of a server. Although servlets can respond to any types of requests, they are commonly used to extend the applications hosted by web servers. Servlets are the Java counterpart to other dynamic Web content technologies such as PHP and ASP.NET. In other words, a Servlet is an object that receives a request and generates a response based on that request.
An Applet is for client side execution, generally graphical components.
Servlet is for server side execution, with no graphical components, but can return HTML or any kind of data (generally called a service).

Categories

Resources