163 subscribers
3.42K photos
24 videos
39 files
371 links
Link: @java_posts

Contact: java.response.email@gmail.com
Download Telegram
Click Open to continue.

Now select Apply and Close option. It will add the jar file to our project.

Step5: Create a HTML or JSP file

Now, our first web application is almost ready. We can create HTML pages that we want to display on our website.

To create an HTML page, right-click on the WebContent folder and select the New HTML file option from the New-> HTML File menu with the name index.html.
<!DOCTYPE html>
<html>
<head>
<meta charset=<em>"UTF-8"</em>>
<title>First Web Application</title>
</head>
<body>
<h1>Welcome</h1>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">News</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
</ul>
</body>
</html>
Step6: Map the File

Now, map this file in the web.xml file. The web.xml is a deployment descriptor for the Servlet applications. Since, Servlet 3.0, we can use annotations instead of the deployment descriptor.

To map a servlet, we have to provide the servlet details such as Servlet name and class. Consider the below code:
<servlet>
<servlet-name>MyHttpTestServlet</servlet-name>
<servlet-class>TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyHttpTestServlet</servlet-name>
<url-pattern>/welcome</url-pattern>
</servlet-mapping>
We can also define our welcome file; a welcome file is the first file of the project that initiates the project, also known as Home. We can define multiple welcome files.

Consider the below code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>BasicWebApplication</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>MyHttpTestServlet</servlet-name>
<servlet-class>TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyHttpTestServlet</servlet-name>
<url-pattern>/welcome</url-pattern>
</servlet-mapping>
</web-app>
From the above code, we can see by default the servlet defines several welcome files. If you want to use any file other than the listed files, you can define that here.

Now, our first web application is ready.

Step7: Run the Application

To run the application, right-click on the project and run it on the server by selecting Run-> Run on Server option.
It will take some time to load the application
The best Java GUI frameworks widely used by Java Developer Community for creating rich GUI based Java applications are

JavaFX
AWT
Apache Pivot
Swing and SwingX
SWT
Best Java GUI Frameworks
JavaFX

The latest flagship of Oracle is JavaFX and is counted at top among the Best Java GUI frameworks. JavaFX is the latest toolkit of Java/Oracle replacing Swing to create rich desktop as well as web applications. Many new Java GUI programs are being developed using JavaFX.
It produces a modern and rich look to its GUI’s when compared to the older Swing and AWT. It is also supported for Mobile apps. Any JavaFX program you write on desktop applications will also work fine on Android and iOS. JavaFX is nice and simple to use.
AWT
The Abstract Window Toolkit (AWT) can be called as very foundation of swing. AWT has optimized performance but still lacks some advanced features.

It is perfect for smaller a Java UI application that doesn’t require various rich user interfaces. This is being used for many years and has proven to be good for Full stack Java developers.

AWT supports Graphical User Interface programming. Some important features of AWT are:

Native user interface components.
Graphics and imaging tools for example shape, font classes.
A robust event-handling model.
Data transfer classes for easy cut-paste actions
Apache Pivot
Apache Pivot is an open-source framework platform for building intensive applications in Java or any JVM-compatible language. It has been released under the Apache License version 2.0.Its main aim is to develop rich internet applications that can also be applied to desktop applications.

It has been developed by Apache. Apache Pivot allows developers to easily construct great cross-platform and well-connected beautiful applications in Java/JVM language (JavaScript, Groovy, or Scala). It provides enhanced productivity and usability features of a UI toolkit.
Swing and SwingX
Swing is the primer framework of choice for building new GUI-based Java applications. Swing has a lot of rich UI components. Swing is the successor to AWT as it fixes and replaces many of its features with enhancing them by adding extra functionality. AWT has more comprehensive components than Swing

SwingX is based on the features of Swing and its main role is to create rich components for swing. It comprises some niche components; one such is such as TreeTable which can do sorting, filtering and searching. It also supports searching with a highlighting option.
SWT
SWT (Standard Widget Toolkit) was created by IBM for Eclipse IDE and is one of the Best Java GUI Frameworks. SWT uses the platform’s native widgets with the help of JNI. It is not related to Swing and AWT at all. It is said to be the alternate version of Swing.

SWT is created by IBM with the main purpose to create a native GUI. It is fast and can be run on the Eclipse IDE. When compared to Swing, it still requires native DLLs across different systems in use. Its users are decreasing day by day as more comprehensive Java GUI tools emerge in the market.
Java pinned «Chapter 4: Java GUI Programming 1. GUI Programming with AWT 2. Label 3. Examples 4. MouseEvent and MouseListener Interface 5. KeyEvent and KeyListener interface 6. Nested Classes 7. Adaptor Class Event Listeners 8. An Introduction to Swing 9. Content…»
Java
Chapter 5: Object-Oriented Programming 1. Why OOP ? 2. Java Constructor 3. Accessing Parent Class Variables 4. The Java OOP Concepts 5. Abstraction 6. Encapsulation 7. Polymorphism 8. Inheritance 9. Association 10. Aggregation 11. Composition 12.…
What is OOPs Concept ?
Object-oriented programming is a core of Java Programming, which is used for designing a program using classes and objects. OOPs, can also be characterized as data controlling for accessing the code. In this approach, programmers define the data type of a data structure and the operations that are applied to the data structure.
What is OOPs in Java ?
OOps in java is to improve code readability and reusability by defining a Java program efficiently. The main principles of object-oriented programming are abstraction, encapsulation, inheritance, and polymorphism. These concepts aim to implement real-world entities in programs.