Can we define a class inside a jsp page?



Can we define a class inside a jsp page?..

Answer / Suraj Singh

<strong>Important:</strong> It is generally discouraged to define classes directly within JSP pages due to maintainability, readability, and reusability concerns. However, if you need to define a simple Java class for the scope of a single JSP page or as a temporary solution, you can use <code><%! public class MyClass { ... } %></code> (Declare) and <code><% MyClass myObject = new MyClass(); %></code> (Create instance).

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More JSP Interview Questions

How to find out the name of the http method using jsp el?

1 Answers  


what is difference between redirect and forward method?

12 Answers   Polaris, TCS, Wipro,


Is the session object always created on the jsp page, is it possible to disable its creation?

1 Answers  


What does .com stand for?

1 Answers  


What is dynamic web project?

1 Answers  


What is c tag in jsp?

1 Answers  


What is application scope in jsp?

1 Answers  


How do I create a dynamic web project?

1 Answers  


Which jsp implicit objects are thread safe?

1 Answers  


What are the jsp tags?

1 Answers  


How can we prevent implicit session creation in jsp?

1 Answers  


Explain various implicit objects in expression language.

1 Answers  


Categories