Browsed by
Tag: java 12 features

Can Abstract Class Be Instantiated

Can Abstract Class Be Instantiated

No abstract class cannot be instantiated i.e you cannot create a new object of this class No, an abstract class cannot be instantiated in Java. An abstract class is a class that is declared with the abstract keyword. It may have abstract methods (methods without a body) that must be implemented by its subclasses. Abstract classes cannot be instantiated on their own because they may contain incomplete or abstract methods, and it doesn’t make sense to create objects of an…

Read More Read More

What is session tracking and how do you track a user session in servlets?-

What is session tracking and how do you track a user session in servlets?-

  Session tracking is a mechanism that servlets use to maintain state about a series requests from the same user across some period of time. The methods used for session tracking are: a) User Authentication – occurs when a web server restricts access to some of its resources to only those clients that log in using a recognized username and password. b) Hidden form fields – fields are added to an HTML form that are not displayed in the client’s…

Read More Read More

What is Static Initializer Code

What is Static Initializer Code

: A class can have a block of initializer code that is simply surrounded by curly braces and labeled as static e.g. Code: public class Demo{ static int =10; static{ System.out.println(�Hello world�); } } And this code is executed exactly once at the time of class load In Java, a static initializer block is a block of code within a class that is executed only once when the class is loaded into the Java Virtual Machine (JVM). It is used…

Read More Read More

What is Inet address

What is Inet address

?– Every computer connected to a network has an IP address. An IP address is a number that uniquely identifies each computer on the Net. An IP address is a 32-bit number. In Java, InetAddress is a class that represents an Internet Protocol (IP) address. It is part of the java.net package and provides methods for working with IP addresses. The InetAddress class can be used to create instances representing both IPv4 and IPv6 addresses. Here’s a brief overview of…

Read More Read More

What do you Understand by Context Initialization Parameters

What do you Understand by Context Initialization Parameters

The context-param element contains the declaration of a web application’s servlet context initialization parameters. Namevalue The Context Parameters page lets you manage parameters that are accessed through the ServletContext.getInitParameterNames and ServletContext.getInitParameter methods. In the context of Java web applications, context initialization parameters refer to the configuration settings that are defined at the level of a web application’s ServletContext. The ServletContext is an interface in the Java Servlet API that provides a way for servlets to interact with their web application…

Read More Read More

Explain the methods, rebind() and lookup() in Naming class?-

Explain the methods, rebind() and lookup() in Naming class?-

rebind() of the Naming class(found in java. rmi) is used to update the RMI registry on the server machine. Naming. rebind(”AddSever”, AddServerImpl); lookup() of the Naming class accepts one argument, the rmi URL and returns a reference to an object of type AddServerImpl. I’m sorry, but there seems to be a misunderstanding. As of my last knowledge update in January 2022, there are no rebind() and lookup() methods in the Naming class in Core Java. In Java, the Naming class…

Read More Read More

Is JSP Technology Extensible

Is JSP Technology Extensible

YES. JSP technology is extensible through the development of custom actions, or tags, which are encapsulated in tag libraries. Yes, JavaServer Pages (JSP) technology is extensible. JSP allows developers to create custom tags, known as JSP custom tags or simply custom tags, to encapsulate reusable functionality. This extensibility enables developers to extend the standard JSP functionality and create modular and maintainable web applications. Custom tags in JSP provide a way to separate the logic of a web application into reusable…

Read More Read More

How do you pass data (including JavaBeans) to a JSP from a servlet?-

How do you pass data (including JavaBeans) to a JSP from a servlet?-

?– (1) Request Lifetime: Using this technique to pass beans, a request dispatcher (using either “include” or forward”) can be called. This bean will disappear after processing this request has been completed. Servlet: request. setAttribute(”theBean”, myBean); RequestDispatcher rd = getServletContext(). getRequestDispatcher(”thepage. jsp”); rd. forward(request, response); JSP PAGE:<jsp: useBean id=”theBean” scope=”request” class=”. . . . . ” />(2) Session Lifetime: Using this technique to pass beans that are relevant to a particular session (such as in individual user login) over a…

Read More Read More

How do you Pass Control From One JSP Page to Another

How do you Pass Control From One JSP Page to Another

Use the following ways to pass control of a request from one servlet to another or one jsp to another. First is RequestDispatcher object‘s forward method to pass the control. Second is response.sendRedirect method. In Advanced Java, when you want to pass control from one JSP (JavaServer Pages) page to another, you typically use mechanisms like: Request Dispatching: You can use RequestDispatcher to forward or include the content of another JSP page. The RequestDispatcher is obtained from the ServletRequest object….

Read More Read More

Can a lock be acquired on a class?

Can a lock be acquired on a class?

Yes, a lock can be acquired on a class. This lock is acquired on the class’s Class object. Yes, in Java, it is possible to acquire a lock on a class. In Java, every class and object has an associated lock, also known as a monitor. This lock is used to control access to the critical section of code to ensure that only one thread can execute the code block at a time. To acquire a lock on a class, you can…

Read More Read More