1>What is RequestDispatcher Interface.
The RequestDispacher interface gives the facility of dispatching the request to another ass page it could be HTML, servlet, or JSP. This interceptor can likewise be utilized to incorporate the substance of another page.
That have 2 technique for that
forward() and include()
Forward a request from a servlet to another resource (servlet, JSP record, or HTML document) on the server.
Include the substance of a resource (servlet, HTML file, or JSP page) in the reaction.
2> What is the difference between ServletConfig and ServletContext?
The web container makes the object of ServletConfig for each servlet whereas the object of ServletContext is made for each web application.
Essentially, ServletConfig and ServletContext are separate from one another based on scope and accessibility.
- In a single web application on a specific JVM ServletConfig object refers to a single Servlet though, the ServletContext object is referred to as basic to all Servlet and different parts.
- ServletConfig object boundaries resemble the nearby boundary though, ServletContext object boundaries resemble the global parameter.
- ServletConfig name value boundaries are characterized inside the <servlet></servlet> tag in web.xml document though, the ServletContext name-value parameter are characterized outside the Servlet tag be that as it may, inside the <context-param></context param> tag.
- ServletConfig article can be get utilizing getServletConfig() technique while, ServletContext item can be get utilizing getServletConfig().getServletContext() or getServletContext() strategy.
3>What do you mean by the sending descriptor?
A sending descriptor depends on XML (Extensible Markup Language) that upholds .xml expansion. It is utilized to portray a part’s arrangement settings. A J2EE application and its module, both have their sending descriptor.
4> What are authorization and authentication?
An authorization is a cycle by which admittance to a technique or resources is resolved. It depends on the assurance of whether the principle related to a request through confirmation is in a given security job. A security job can be clarified as an intelligent gathering of clients characterized by the individual who collects the application. A deployer maps the security roles to security identities. Security personalities might be standards or gatherings in the operational environment.
Authentication vs. Authorization
The distinction between authentication and authorization is significant in seeing how RESTful APIs are functioning and why association endeavors are either acknowledged or denied:
Authentication is the check of the qualifications of the association endeavor. This interaction comprises of sending the qualifications from the distant access customer to the far-off access server in either plaintext or encrypted form by utilizing an authentication protocol.
Authorization is the confirmation that the association endeavor is permitted. Approval happens after effective validation.
All in all: Authentication is expressing that you are who are you are and Authorization is asking as to whether you approach a specific resource.
I realize that it is somewhat confounding that in REST APIs we are utilizing the Authorization header for doing Authentication (or both) yet if we recollect that when calling an API we are mentioning an admittance to certain resources it implies that the server should know if it should offer admittance to that resources, henceforth when creating and planning RESTful API Authorization header sounds fine and dandy.
5>Difference among ServletConfig and ServletContext in Java Servlet
ServletConfig and ServletContext, are objects made at the hour of servlet introduction and used to give some underlying boundaries of design data to the servlet. However, the distinction lies in the way that data shared by ServletConfig is for a particular servlet, while data shared by ServletContext is accessible for all servlets in the web application.
ServletConfig is an item containing some initial parameters or design data made by Servlet Container and passed to the servlet during the introduction.
ServletConfig is for a specific servlet, which implies one should store servlet explicit data in web.xml and recover them utilizing this item.
Assume, one is building a task gateway and wants to share distinctive email ids (which may get change after some time) to recruiters and occupation candidates.
Thus, he chooses to compose two servlets one for dealing with the recruiter’s request and another for the work candidate.
Where to store email-ids?
Put email-id as a name-value pair for various servlet inside web.xml which can additionally be recovered utilizing getServletConfig().getInitParameter(“name”) in the servlet.
- ServletContext is the article made by Servlet Container to share starting initial parameters or setup data to the entire application.
Assume, the name of one’s work gateway is “NewWebsite.tg”. Showing the site name at the highest point of pages conveyed by various servlets, one requirement to store the site name in each servlet welcoming excess. Since the data shared by ServletContext can be gotten to by each Servlet, it is smarter to go with ServletContext and retrieve the site name utilizing getServletContext.getInitParameter(“Name”) at whatever point required.
6>What is JDBC Savepoint? How to utilize it?
Here and there an exchange can be gathering of different statements and we might want to roll back to a specific point in the exchange. JDBC Savepoint helps us in making designated checkpoint in exchange and we can roll back to that specifically designated checkpoint.
Any savepoint made for an exchange is automatically released and becomes invalid when the exchange is submitted, or when the whole exchange is moved back. Rolling an exchange back to a savepoint automatically releases.
7> What is the difference between java. util.Date and java.sql.Date?
java.util.Date contains data about the date and time through java.sql.Date contains data just about the date, it doesn’t have time data. So on the off chance that you need to keep time data in the information base, it is prudent to utilize Timestamp or DateTime fields.
8>Prepared Statements are faster. Why?
Prepared statement execution is faster than direct execution because the statement is compiled just a single time. Prepared statements and JDBC drivers are associated with one another during execution, and there are no connection overheads.
9>Mention what is the difference between PUT and POST?
“PUT” puts a document or resources at a specific URI and precisely at that URI. If there is as of now a record or resources at that URI, PUT changes that document or resources. On the off chance that there is no resources or record there.
POST sends information on a specific URI and expects that the resource at that URI should manage the request. The web server now can choose how to manage the information with regards to indicated resources
PUT is of idempotent importance, invoking it any number of times will not have an impact on resources.
10> State the differences between JAR and WAR files in Java?
The differences between the JAR document and the WAR record are the following:
- JAR document stands Java Archive record that permits us to many numerous files into a single document. While, WAR documents represent Web Application Archive records that store XML, java classes, and JavaServer Pages, and so on, for Web Application purposes.
- JAR files hold Java classes in a library. While WAR documents store the records in the ‘lib’ registry of the web application.
- All the endeavor Java Bean classes and EJB sending descriptors present in the EJB module are pressed and put away in a JAR document with .container expansion. While, the WAR record contains web modules, for example, Servlet classes, GIFs, HTML documents, JSP documents, and so forth, with .war expansion.
Call the Trainer and Book your free demo Class for JAVA now!!!
© Copyright 2019 | Sevenmentor Pvt Ltd.