This is a discussion on Java/J2EE interview Questions within the Interview Questions & Answers and Tips forums, part of the DiscussWeb IT Curriculum category; what are include directives? The include directive informs the JSP engine to include the content of the resource in thecurrent ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#11
| |||
| |||
| what are include directives? The include directive informs the JSP engine to include the content of the resource in thecurrent JSP page. Below is the syntax for include statement. <%@ include file="Filename" %> Below is a code snippet which shows include directive in action <html> <head> <title>Directive in action</title> </head> <%@ include file="/companyname.html" %> <body> <h1>Directive in action</h1> </body> </html>companyname.html contains the following: <p>Koirala and Koirala Limited</p>
__________________ Venkat knowledge is Power |
|
#12
| |||
| |||
| How does JSP engines instantiate tag handler classes instances? JSP engines will always instantiate a new tag handler instance every time a tag is encounteredin a JSP page. A pool of tag instances are maintained and reusing them where possible.When a tag is encountered, the JSP engine will try to find a Tag instance that is not beingused and use the same and then release
__________________ Venkat knowledge is Power |
|
#13
| |||
| |||
| what’s the difference between JavaBeans and taglib directives? JavaBeans and taglib fundamentals were introduced for reusability. But following are the major differences between them:- √Taglib are for generating presentation elements while JavaBeans are good for storing information and state.√Use custom tags to implement actions and JavaBeans to present information.
__________________ Venkat knowledge is Power |
|
#14
| |||
| |||
| what are the different scopes an object can have in a JSP page? There are four scope which an object can have in a JSP page:- Page Scope Objects with page scope are accessible only within the page. Data only is valid for the current response. Once the response is sent back to the browser then data is no more valid. Even if request is passed from one page to other the data is lost. Request Scope Objects with request scope are accessible from pages processing the same request in which they were created. Once the container has processed the request data is invalid.Even if the request is forwarded to another page, the data is still available though not ifa redirect is required. Session Scope Objects with session scope are accessible in same session. Session is the time users spend using the application, which ends when they close their browser or when they go to another Web site. So, for example, when users log in, their user name could be stored in the session and displayed on every page they access. This data lasts until they leave the Web site or log out. Application Scope Application scope objects are basically global object and accessible to all JSP pages which lie in the same application. This creates a global object that's available to all pages.Application scope variables are typically created and populated when an application starts and then used as read-only for the rest of the application.
__________________ Venkat knowledge is Power |
|
#15
| |||
| |||
| what are different implicit objects of JSP? pageContext :- The PageContext object.pageScope :- A Map of all the objects that have page scope.requestScope :- A Map of all the objects that have request scope.sessionScope :- A Map of all the objects that have session scope.applicationScope :- A Map of all the objects that have application scope. param :- A Map of all the form parameters that were passed to your JSP page (for example,the HTML <input name="ourName" type="text"/> is passed to your JSP page as aform parameter).paramValues :- HTML allows for multiple values for a single form parameter. This is aMap of all the parameters, just like param, but in this object the values are an arraycontaining all of the values for a given parameter in the event that there's more than one.header :- A Map of all the request headers.headerValues :- For the same reasons as paramValues, a headerValues object is provided.cookie :- A Map of all the cookies passed to your JSP. The value returned is a Cookieobject.initParam :- A Map that maps context initialization parameter names to their parametervalues.
__________________ Venkat knowledge is Power |
|
#16
| |||
| |||
| what are different Authentication Options available in servlets? There are four ways of authentication:- √HTTP basic authentication √HTTP digest authentication √HTTPS client authentication √Form-based authenticationLet’s try to understand how the above four ways work.
__________________ Venkat knowledge is Power |
|
#17
| |||
| |||
| Can you explain JDBCRealm? A realm is a "database" of usernames, passwords, and user roles. When we say JDBCrealmwe mean all these attributes are stored in table. In order to connect to JDBC you need to make a context.xml and save the same in “META-INF “folder of the web application.Below is the context.xml snippet. <Context path="/security" docBase="security" debug="0"> <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99" driverName="com.mysql.jdbc.Driver"connectionURL="j dbc:mysql://localhost:3306/security?autoReconnect=true" connectionName="MyConn" connectionPassword="Password1" userTable="tblusers" userNameCol="username" userCredCol="password" userRoleTable="user_roles" roleNameCol="role_name" /> </Context>
__________________ Venkat knowledge is Power |
|
#18
| |||
| |||
| How did you implement caching in JSP? OSCache is an open-source caching library that's available free of charge from theOpenSymphony organization (for more details visit OSCache - OSCache). OSCache has a set of JSP tags that make it easy to implement page caching in your JSP application.Following are some Cache techniques it fulfills:-Cache entry An object that's stored into a page cache is known as a cache entry. In a JSP application,a cache entry is typically the output of a JSP page, a portion of a JSP page, or a servlet. 218Cache keyA page cache is like a hash table. When you save a cache entry in a page cache, you mustprovide a cache key to identify the cache data. You can use keys like URI, other parameterslike username, ipaddress to indentify cache data.Cache durationThis is the period of time that a cache entry will remain in a page cache before it expires.When a cache entry expires, it's removed from the cache and will be regenerated again.Cache scopeThis defines at what scope the data is stored application or session scope.<os:cache time="60"><%= new java.util.Date().toString() %></p></os:cache>The above tag says that refresh after every 60 seconds the user requests data. So if user1is requesting the page it will display fresh date and if an other user requests with in 60seconds it will show same data. If any other user requests the page after 60 second he willagain see refreshed date.
__________________ Venkat knowledge is Power |
|
#19
| |||
| |||
| What is the difference between Servletcontext and ServletConfig ? ServletConfig contains configuration data for the servlet in the form of name and valuepairs.Using the ServletConfigwe get reference to the ServletContext object. ServletContextgives the servlet access to information about its runtime environment such as web serverlogging facilities, version info, URL details, web server attributes etc.
__________________ Venkat knowledge is Power |
|
#20
| |||
| |||
| How do we prevent browser from caching output of my JSP pages? You can prevent pages from caching JSP pages output using the below code snippet.<%response.setHeader("Cache-Control","no-cache"); //HTTP 1.1response.setHeader("Pragma","no-cache"); //HTTP 1.0response.setDateHeader ("Expires", 0); //prevents caching at the proxy server%>
__________________ Venkat knowledge is Power |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Greetings from Java J2EE web development team | tenax_technologies | Introductions | 1 | 07-04-2009 11:53 PM |
| Asp Interview Questions | sureshbb | ASP and ASP.NET Programming | 35 | 10-29-2008 07:58 PM |
| CSS Interview Questions And Answers | Sabari | Interview Questions & Answers and Tips | 137 | 11-25-2007 08:38 PM |
| HR Interview Questions with Answers | Sabari | Interview Questions & Answers and Tips | 63 | 11-23-2007 05:13 AM |
| Interview Questions | shiva | Interview Questions & Answers and Tips | 6 | 08-24-2007 01:28 AM |
Our Partners |