Top 50 JSP Interview Questions & Answers JSP is a standard extension of Java and is defined on top of Servlet .. interview. Download PDF. Dear readers, these JSP Interview Questions have been designed specially to get you As per my experience good interviewers hardly plan to ask any particular question during continue based on further discussion and what you answer. JSP Interview Questions and Answers for Experienced, Beginners, Freshers Here I am providing some important JSP interview questions with answers to help.
|Language:||English, Spanish, French|
|Distribution:||Free* [*Registration Required]|
Java/J2EE Interview - Top 50 JSP Interview Questions and Answers for developers. The primary level of JSP Interview Questions. .. We've observed from our experience that you won't struck in an interview just after reading the lengthy. JSP Interview Questions and Answers. What is a JSP and what JSPs are normal HTML pages with Java code pieces embedded in them. JSP pages are saved. There is a list of top 40 frequently asked JSP interview questions and answers for freshers and professionals. If you know any JSP interview question that has not.
Static pages are always included using JSP include directive. This way the inclusion is performed in the translation phase once. Note that a relative URL must be supplied for file attribute. Although static resources may be included, it is not preferred as each request requires inclusion.
JComponent is a subclass of Container. It contains other Components and JComponents. How can a thread safe JSP page be implemented? It can be done by having them implemented by the SingleThreadModel Interface. We can use pageContext to get and set attributes with different scopes and to forward request to other resources.
We can configure init params for JSP similar to servlet in web. The only thing differs from servlet is jsp-file element where we need to provide the JSP page location. JSP pages are mostly used for view purposes and all the business logic should be in the servlet or model classes. Below is the sample code for this:. We can disable scripting elements in JSP pages through deployment descriptor configuration like below. JSP action elements or action tags are HTML like tags that provide useful functionalities such as working with Java Bean, including a resource, forwarding the request and to generate dynamic XML elements.
JSP action elements always starts with jsp: Some of the important action elements are jsp: The difference between JSP include directive and include action is that in include directive the content to other resource is added to the generated servlet code at the time of translation whereas with include action it happens at runtime. Another difference is that in JSP include action, we can pass params to be used in the included resource with jsp: When the included resource is static such as header, footer, image files then we should use include directive for faster performance but if the included resource is dynamic and requires some parameters for processing then we should use include action tag.
Most of the times we use JSP for view purposes and all the business logic is present in servlet code or model classes. We also use request params, headers, cookies and init params in JSP to create response views. We can use scriptlets and JSP expressions to retrieve attributes and parameters in JSP with java code and use it for view purpose.
JSP Expression Language provides many implicit objects that we can use to get attributes from different scopes and parameter values. Note that these are different from JSP implicit objects and contains only the attributes in given scope.
Most of the times, you can find them in the example projects and you can use them. These jars are container specific, for example in Tomcat, we need to include jstl. Fortunately JSP is extendable and we can create our own custom tags to perform certain operations. We can add custom tag library in JSP page using taglib directive and then use it. This can be very useful for user when the number is really long. So we want some custom tags like below:.
Based on the number and format passed, it should write the formatted number in JSP page, for the above example it should print , All we need to do it to include it in the JSP page using taglib directive.
To handle exceptions thrown by the JSP page, all we need is an error page and define the error page in JSP using page directive. To create a JSP error page, we need to set the page directive attribute isErrorPage value to true, then we can access exception implicit object in the JSP and use it to send a customized error message to the client.
Below code snippet provide sample usage. We can use c: If we have multiple servlet and servlet-mapping elements in deployment descriptor for a single servlet or JSP page, then container will initialize an object for each of the element and all of these instances will have their own ServletConfig object and init params.
Yes why not, I have seen some developers getting confused with this. We can use JSP page directive session attribute to indicate compiler to not create session by default.
To disable the session creation, we can use it like below.
PrintWriter is the actual object responsible for writing the content in response. JspWriter uses the PrintWriter object behind the scene and provide buffer support. When the buffer is full or flushed, JspWriter uses the PrintWriter object to write the content into response.
Please let me know if I have missed any important JSP interview question, I will be adding more to the list in the future. If you have come this far, it means that you liked what you are reading. Why not reach little more and connect with me directly on Facebook or Twitter. I would love to hear your thoughts and opinions on my articles directly. Recently I started creating video tutorials too, so do check out my videos on YouTube.
If you use type without class or beanName, no Bean is instantiated. Question 5: How can one Jsp Communicate with Java file. Question 6: This is a fact based interview question what it checks is how much coding you do in JSP if you are doing it frequently you definitely know them. Implicit object is the object that is created by web container provides to a developer to access them in their program using JavaBeans and Servlets.
These objects are called implicit objects because they are automatically instantiated. They are request, response, pageContext, session, and application, out, config, page, and exception.
Question 7: In JSP page how can we handle runtime exception? We can use the errorPage attribute of the page directive to have uncaught run-time exceptions automatically forwarded to an error processing page. It will redirect the browser to the JSP page error. Within error. Question 8: Question 9: How can you pass information form one jsp to included jsp: This JSP interview question is little tricky and fact based.
Question Ans tag library is a collection of custom tags.
Custom actions helps recurring tasks will be handled more easily they can be reused across more than one application and increase productivity. JSP tag libraries are used by Web application designers who can focus on presentation issues rather than being concerned with how to access databases and other enterprise services.
Some of the popular tag libraries are Apache display tag library and String tag library. You can also check my post on display tag library example on Spring.
Please contribute any interview questions asked to you guys on JSP Interview or if you are looking for the answer of any JSP questions, I will try to help you. Share to Twitter Share to Facebook. United States. Anonymous said JSP Questions are rather good and answers are better. October 10, at May 23, at April 13, at October 14, at 4: Can we call Servlet from Jsp??? November 24, at September 4, at Hi how to used doget and dopost method in jsp.
November 17, at Newer Post Older Post Home.