41 | Q | What is the meaning of response has already been committed error? |
|
| A | You will get this error only when you try to redirect a page after you already have flushed the output buffer. This happens because HTTP specification force the header to be set up before the lay out of the page can be shown. When you try to send a redirect status, your HTTP server cannot send it right now if it hasn't finished to set up the header. Simply it is giving the error due to the specification of HTTP 1.0 and 1.1 |
|
|
|
|
|
42 | Q | How do I use a scriptlet to initialize a newly instantiated bean? |
|
| A | A jsp:useBean action may optionally have a body. If the body is specified, its contents will be automatically invoked when the specified bean is instantiated (Only at the time of instantiation.) Typically, the body will contain scriptlets or jsp:setProperty tags to initialize the newly instantiated bean, although you are not restricted to using those alone. |
|
|
|
|
|
43 | Q | What is JSP? |
|
| A | JSP is a server side scripting technology. JSP allows Java as well as a few special tags to be embedded into a web file (HTML/XML, etc). The suffix must ends with .jsp. |
|
|
|
|
|
44 | Q | What are JSP Actions? |
|
| A | JSP actions use constructs in XML syntax to control the behavior of the servlet engine. You can dynamically insert a file, reuse JavaBeans components, forward the user to another page, or generate HTML for the Java plugin. Available actions include: jsp:include, jsp:useBean, jsp:setProperty, jsp:getProperty, jsp:forward and Jsp: plugin |
|
|
|
|
|
45 | Q | What is the difference between ServletContext and ServletConfig? |
|
| A | The ServletConfig gives the information about the servlet initialization parameters. The servlet engine implements the ServletConfig interface in order to pass configuration information to a servlet. The server passes an object that implements the ServletConfig interface to the servlet's init() method. The ServletContext gives information about the container. The ServletContext interface provides information to servlets regarding the environment in which they are running. It also provides standard way for servlets to write events to a log file. |
|
|
|
|
|
46 | Q | How can a servlet refresh automatically? |
|
| A | We can use a client-side Refresh or Server Push |
|
|
|
|
|
47 | Q | What is Server side push? |
|
| A | Server Side push is useful when data needs to change regularly on the clients application or browser, without intervention from client. The mechanism used is, when client first connects to Server, then Server keeps the TCP/IP connection open. |
|
|
|
|
|
48 | Q | What is client side refresh? |
|
| A | The standard HTTP protocols ways of refreshing the page, which is normally supported by all browsers. <META HTTP-EQUIV="Refresh" CONTENT="5; URL=/servlet/MyServlet/"> This will refresh the page in the browser automatically and loads the new data every 5 seconds. |
|
|
|
|
|
49 | Q | What is the Max amount of information that can be saved in a Session Object ? |
|
| A | There is no such limit on the amount of information that can be saved in a Session Object. The only limit is the Session ID length , which should not exceed more than 4K. |
|
|
|
|
|
50 | Q | Why should we go for inter servlet communication? |
|
| A | The three major reasons to use inter servlet communication are: a) Direct servlet manipulation - allows to gain access to the other currently loaded servlets and perform certain tasks (through the ServletContext object) b) Servlet reuse - allows the servlet to reuse the public methods of another servlet. c) Servlet collaboration - requires to communicate with each other by sharing specific information (through method invocation) |
|
|
|
|
|
51 | Q | What is a output comment? |
|
| A | A comment that is sent to the client in the viewable page source. The JSP engine handles an output comment as un interpreted HTML text, returning the comment in the HTML output sent to the client. You can see the comment by viewing the page source from your Web browser. |
|
|
|
|
|
52 | Q | What is a Hidden Comment |
|
| A | Hidden Comments are JSP comments. A comments that documents the JSP page but is not sent to the client. The JSP engine ignores a hidden comment, and does not process any code within hidden comment tags. |
|
|
|
|
|
53 | Q | What are the differences between a session and a cookie? |
|
| A | Session is stored in server but cookie stored in client. Session should work regardless of the settings on the client browser. There is no limit on the amount of data that can be stored on session. But it is limited in cookie. Session can store objects and cookies can store only strings. Cookies are faster than session. |
|
|
|
|
|
54 | Q | What is HttpTunneling? |
|
| A | HTTP tunneling is used to encapsulate other protocols within the HTTP or HTTPS protocols. Normally the intranet is blocked by a firewall and the network is exposed to the outer world only through a specific web server port, that listens for only HTTP requests. To use any other protocol, that by passes the firewall, the protocol is embedded in HTTP and send as HttpRequest. |
|
|
|
|
|
55 | Q | How to pass information from JSP to included JSP? |
|
| A | By using <jsp:param> tag. |
|
|
|
|
|
56 | Q | What is the better way to enable thread-safe servlets and JSPs? SingleThreadModel Synchronization? |
|
| A | The better approach is to use synchronization. Because SingleThreadModel is not scalable. SingleThreadModel is pretty resource intensive from web server's perspective. The most serious issue is when the number of concurrent requests exhaust the servlet instance pool. In that case, all the un serviced requests are queued until something becomes free - which results in poor performance. |
|
|
|
|
|
57 | Q | What is the difference between ServletContext and PageContext? |
|
| A | ServletContext gives the information about the container and PageContext gives the information about the Request |
|
|
|
|
|
58 | Q | Why in Servlet 2.4 specification SingleThreadModel has been deprecated? |
|
| A | SingleThreadModel is pretty resource intensive from web server's perspective. When the number of concurrent requests exhaust the servlet instance pool, all the un serviced requests are queued until something becomes free - which results in poor performance. |
|
|
|
|
|
59 | Q | How do you pass data (including JavaBeans) to a JSP from a servlet? |
|
| A | By forwarding the request to the servlet ( the data must be there in the request scope) we can pass the data from a JSP to servlet. Also we can use a session to pass the data. |
|
|
|
|
|
60 | Q | How can I set a cookie? |
|
| A | Cookie c = new Cookie("name","value"); response.addCookie(c); |
|