<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    JSP, Servlets Interview questions

        Here you can find out a list of interview questions for jsp and servlets. These questions are often asked by the interviewer for jsp interview and servlet interview. We put our  maximum effort to make this answers error free. But still there might be some errors. If you feel out any answer given for any  question is wrong, please, please inform us by clicking on report bug button provided below.
        In this section we are offering interview questions for JSP and Servlets only. Since JSP and Servlets are almost identical technology, there is only one section for both JSP and Servlet interview questions. If you need interview questions for any other java related technologies , please check the relevant sections.

    1 Q What is the difference between JSP and Servlets ?

    A

    JSP is used mainly for presentation only. A JSP can only be HttpServlet that means the only supported protocol in JSP is HTTP. But a servlet can support any protocol like HTTP, FTP,SMTP etc.




    2 Q What is difference between custom JSP tags and beans?

    A

    Custom JSP tag is a tag you defined. You define how a tag, its attributes and its body are interpreted, and then group your tags into collections called tag libraries that can be used in any number of JSP files. To use custom JSP tags, you need to define three separate components: the tag handler class that defines the tag's behavior ,the tag library descriptor file that maps the XML element names to the tag implementations and the JSP file that uses the tag library

    JavaBeans are Java utility classes you defined. Beans have a standard format for Java classes. You use tags

    Custom tags and beans accomplish the same goals -- encapsulating complex behavior into simple and accessible forms. There are several differences:

    Custom tags can manipulate JSP content; beans cannot. Complex operations can be reduced to a significantly simpler form with custom tags than with beans. Custom tags require quite a bit more work to set up than do beans. Custom tags usually define relatively self-contained behavior, whereas beans are often defined in one servlet and used in a different servlet or JSP page. Custom tags are available only in JSP 1.1 and later, but beans can be used in all JSP 1.x versions.




    3 Q What are the different ways for session tracking?

    A

    Cookies, URL rewriting, HttpSession, Hidden form fields




    4 Q What mechanisms are used by a Servlet Container to maintain session information?

    A

    Cookies, URL rewriting, and HTTPS protocol information are used to maintain session information




    5 Q Difference between GET and POST

    A

    In GET your entire form submission can be encapsulated in one URL, like a hyperlink.query length is limited to 255 characters, not secure, faster, quick and easy. The data is submitted as part of URL.

    In POST data is submitted inside body of the HTTP request. The data is not visible on the URL and it is more secure.



     

    6 Q What is session?

    A

    The session is an object used by a servlet to track a user's interaction with a Web application across multiple HTTP requests. The session is stored on the server.




    7 Q What is servlet mapping?

    A

    The servlet mapping defines an association between a URL pattern and a servlet. The mapping is used to map requests to Servlets.




    8 Q What is servlet context ?

    A

    The servlet context is an object that contains a information about the Web application and container.  Using the context, a servlet can log events, obtain URL references to resources, and set and store attributes that other servlets in the context can use.




    9 Q What is a servlet ?

    A

    servlet is a java program that runs inside a web container.




    10 Q Can we use the constructor, instead of init(), to initialize servlet?

    A

    Yes. But you will not get the servlet specific things from constructor. The original reason for init() was that ancient versions of Java couldn’t dynamically invoke constructors with arguments, so there was no way to give the constructor a ServletConfig. That no longer applies, but servlet containers still will only call your no-arg constructor. So you won’t have access to a ServletConfig or ServletContext.




    12 Q How many JSP scripting elements are there and what are they?

    A

    There are three scripting language elements: declarations, scriptlets, expressions.




    13 Q How do I include static files within a JSP page?

    A

    Static resources should always be included using the JSP include directive. This way, the inclusion is performed just once during the translation phase. 




    14 Q How can I implement a thread-safe JSP page?

    A

    You can make your JSPs thread-safe adding the directive <%@ page isThreadSafe="false" % > within your JSP page.




    15 Q What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?

    A

    In request.getRequestDispatcher(path) in order to create it we need to give the relative path of the resource. But in   resourcecontext.getRequestDispatcher(path) in order to create it we need to give the absolute path of the resource.




    16 Q What are the lifecycle of JSP?

    A

    When presented with JSP page the JSP engine does the following 7 phases.

    • Page translation: -page is parsed, and a java file which is a servlet is created.

    • Page compilation: page is compiled into a class file

    • Page loading : This class file is loaded.

    • Create an instance :- Instance of servlet is created

    • jspInit() method is called

    • _jspService is called to handle service calls

    • _jspDestroy is called to destroy it when the servlet is not required.




    17 Q What are context initialization parameters?

    A

    Context initialization parameters are specified by the <context-param> in the web.xml file, these are initialization parameter for the whole application.




    18 Q What is a Expression?

    A

    Expressions are act as place holders for language expression, expression is evaluated each time the page is accessed. This will be included in the service method of the generated servlet.




    19 Q What is a Declaration?

    A

    It declares one or more variables or methods for use later in the JSP source file. A declaration must contain at least one complete declarative statement. You can declare any number of variables or methods within one declaration tag, as long as semicolons separate them. The declaration must be valid in the scripting language used in the JSP file. This will be included in the declaration section of the generated servlet.




    20 Q What is a Scriptlet?

    A

    A scriptlet can contain any number of language statements, variable or expressions that are valid in the page scripting language. Within scriptlet tags, you can declare variables to use later in the file, write expressions valid in the page scripting language, use any of the JSP implicit objects or any object declared with a <jsp:useBean>.  Generally a scriptlet can contain any java code that are valid inside a normal java method. This will become the part of generated servlet's service method.



    My Java study notes.

    posted on 2008-10-21 00:48 mailguest 閱讀(558) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    <2008年10月>
    2829301234
    567891011
    12131415161718
    19202122232425
    2627282930311
    2345678

    導航

    統計

    公告

    ~~~~~~JAVA學習筆記~~~~~~

    常用鏈接

    留言簿(1)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: a级男女仿爱免费视频| 蜜芽亚洲av无码一区二区三区| av午夜福利一片免费看久久| 色播在线永久免费视频| 一本色道久久88亚洲精品综合| 日韩精品久久久久久免费| 亚洲免费视频网站| 四虎在线最新永久免费| 久久乐国产综合亚洲精品| 中国在线观看免费国语版| 亚洲成a人片在线不卡一二三区| 日美韩电影免费看| 一本岛v免费不卡一二三区| 亚洲三区在线观看无套内射| 91免费福利视频| 亚洲视频在线观看不卡| 成人A级毛片免费观看AV网站| 亚洲欧美日韩中文字幕在线一区| 在线观看亚洲免费视频| 一级毛片无遮挡免费全部| 亚洲精品国产精品乱码不99 | 18禁免费无码无遮挡不卡网站| 亚洲天堂电影在线观看| 日韩激情淫片免费看| 无套内射无矿码免费看黄| 亚洲av永久无码精品表情包| 亚洲第一成年免费网站| 免费人成网站永久| 亚洲精品国产成人99久久| 午夜高清免费在线观看| 国产va免费精品| 亚洲女人初试黑人巨高清| 亚洲国产av无码精品| 999久久久免费精品播放| 亚洲av日韩av永久在线观看| 亚洲日韩激情无码一区| 99精品全国免费观看视频| 成人无码精品1区2区3区免费看| 亚洲日本在线免费观看| 亚洲成a人片在线观看国产| 最近中文字幕完整版免费高清|