Learn Java Training from the Best Tutors
Search in
Answered on 17 Nov Learn Servlet
Sadika
Servlets and JSP (JavaServer Pages) are still relevant in the field of Java web development, and many existing systems and applications rely on these technologies. However, the technology landscape evolves, and trends can shift over time. Here are some considerations regarding the relevance of Servlets and JSP:
Legacy Systems:
Stability and Maturity:
Newer Alternatives:
Microservices Architecture:
Separation of Concerns:
Security and Performance:
Integration with Modern Technologies:
Education and Training:
While the usage of Servlets and JSP might not be as prevalent in new greenfield projects as it once was, they continue to play a role in maintaining and evolving existing systems. Additionally, the skills and knowledge gained from working with Servlets and JSP can be valuable for developers, especially those maintaining or upgrading legacy systems. Always check the latest industry trends, community discussions, and official documentation for the most up-to-date information on the relevance of these technologies.
Answered on 17 Nov Learn Servlet
Sadika
When a JavaServer Pages (JSP) file is accessed for the first time, it is translated or compiled into a servlet by the JSP container. This process involves several steps:
Translation:
<% %>
tags and custom tags, into equivalent Java code.Compilation:
Class Loading:
Instantiation:
Execution:
The entire process can be visualized as follows:
JSP File (.jsp) -> JSP Container -> Translation -> Compilation -> Servlet Class (.class) -> Class Loading -> Instantiation -> Execution
During the translation process, the JSP container generates additional Java code to handle tasks such as managing the HTTP request and response objects, setting up the JSP context, and managing session information. The generated servlet code includes methods such as service()
, which is responsible for handling HTTP requests.
The generated servlet is then stored in a directory specific to the servlet container, often within the work
directory of the application server. The generated servlet code can be viewed for debugging purposes, as many application servers provide an option to retain the generated Java source code.
It's worth noting that subsequent requests to the same JSP file do not typically trigger the translation and compilation process again unless the JSP file has been modified. In such cases, the JSP container detects the changes and repeats the translation and compilation steps. This helps improve the performance of JSP-based applications.
Answered 4 days ago Learn Java
Sadika
The ObjectInputStream
and ObjectOutputStream
classes in Java are part of the Java Input/Output (I/O) system and are used for reading and writing objects, respectively. These classes are primarily designed for object serialization, which is the process of converting an object's state into a byte stream and reconstructing the object from that byte stream. Serialization is essential for scenarios like storing objects in files, sending objects over a network, or saving object states between different program executions.
ObjectOutputStream:
writeObject(Object obj)
, which writes the specified object to the underlying stream.ObjectInputStream:
readObject()
, which reads the next object from the input stream and returns it as a generic Object
. The caller must cast the returned object to its appropriate type.It's important to note that for an object to be serializable, its class must implement the Serializable
interface. This interface acts as a marker, indicating that the class can be serialized. If a class does not implement Serializable
, an exception (NotSerializableException
) will be thrown at runtime.
Here's a simple example of a serializable class:
These classes are powerful tools for handling object persistence and communication in Java, allowing objects to be easily saved, transmitted, and reconstructed.
Learn Java Training from the Best Tutors
Answered on 19 Nov Learn Java
Vigneshwar
IT Professional with 8 years of experience in Cloud Software Development
In Java, memory allocation for objects is managed by the Java Virtual Machine (JVM) through a process known as dynamic memory allocation or garbage collection.
Java objects are stored in the heap memory, which is a region of the computer's memory that is managed by the JVM.
The heap is divided into different segments, such as the Young Generation, Old Generation (Tenured), and Perm (or Metaspace).
Newly created objects are initially allocated in the Young Generation and will eventually travel to Old Generation after survival through multiple GC.
read less
Answered on 19 Nov Learn Java
Vigneshwar
IT Professional with 8 years of experience in Cloud Software Development
The do-while
loop is a type of loop in programming that is similar to the while
loop, but with one key difference: the do-while
loop guarantees that the block of code inside the loop is executed at least once, regardless of whether the loop condition is true or false.
Here is a sample do while loop:
do {
// code to be executed
} while (condition);
The flow of a do-while
loop is as follows:
do
statement is executed.do-while
loop.int i = 6;
do {
System.out.println(i);
i++;
} while (i <= 5);
This loop will print the numbers 6.
The loop will execute at least once even if the initial value of i is greater than 5. The loop condition is checked after the first execution of the code block.
read less
Answered on 20 Nov Learn Java
Vivek Joglekar
Wroking in IT industry from last 15 years and and trained more than 5000+ Students. Conact ME
Learn Java Training from the Best Tutors
Answered on 20 Nov Learn Java
Madana Gopal D
Inorder to create custom runtime exception->
create a class and extend it with RuntimeException class and create a constructor with string argument which accepts message and using super keyword send the message to parent class.
Code->
class MyRuntimeException extends RuntimeException{
public MyRuntimeException(String ms){
super(msg);
}
Inorder to create custom compiletime exception->
create a class and extend it with Exception class and create a constructor with string argument which accepts message and using super keyword send the message to parent class.
Code->
class CustomException extends Exception{
public CustomException(String ms){
super(msg);
}
Using throw keyword you can throw this exception where ever you want in yout code.
read lessAnswered on 20 Nov Learn Java
Vivek Joglekar
Wroking in IT industry from last 15 years and and trained more than 5000+ Students. Conact ME
Answered on 21 Nov Learn Java
Vivek Joglekar
Wroking in IT industry from last 15 years and and trained more than 5000+ Students. Conact ME
Learn Java Training from the Best Tutors
Answered on 21 Sep Learn Java
Krishnavalli Singaravelan
UrbanPro.com helps you to connect with the best Java Training Classes in India. Post Your Requirement today and get connected.
Ask a Question
The best tutors for Java Training Classes are on UrbanPro
The best Tutors for Java Training Classes are on UrbanPro
Book a Free Demo