sasikala's blog

JSP Interview / Practicer Questions - II

11. <%a taglib prefix="my" uri="/WEB-INF/myTags.tld" %>
<%--JSP content --%>

The tag handler for my:tag1 is TagHandler and extends TagSupport. What happens when the instance of TagHandler calls the getParent method?

a. A JSPException is thrown
b. The null value is returned
c. A NullPointerException is thrown
d. An IllegalStateException is thrown

Ans : b

12. Which is true about the lifecycle of a Simple tag?

a. The release method is called after the dotag method
b. The setJSPBody method is always called before the dotags method.
c. The setParent and setJSPContext methods are called immediately before the tag attributes are set.

Ans: c

13. Public Class Exampletag extends TagSupport
Private String param;
Public void setParam(String p) { param = p; }
Public int doStartTag () throws JspException {
// insert code here
// more code here

which inserted at line 14. Would be gauaranteed to assign the value of the request scoped attribute param to the local variable p?

Ans. String p = pageContext.getRequest().getAttribute("param");

14. Which are valid method calls on a PageContext object?

Answers :
1. getAttribute("key");
2. findAttribute("key");
3. getAttributeScopt("key");
4. getAttribute("key", PageContext.SESSION_SCOPE);

15. Which is most efficient JspContext method to call to access an attribute that is known to be in application scope?

a. getPageContext()
b. getAttribute(String);
c. findAttribute(String);
d. getAttribute(String int);

Ans : d

16. What is the best strategy when implementing a custom tag for finding the value of an attribute whose scope is unknown?

a. Check all scopes with single
pageContext.getAttribute(String) call
b. Check all scopes with single
pageContext.findAttribute(string) call
c. Check each scope with calls to
pageContext.getAttribute(String, int)
Ans : b

17. Tag File Model

Ans : 1. The <jsp:doBody> standard action can only be used in Tag Files.
2. The Allowable file extensions for tag Files are .tag and .tagx
3. For each attribute declared and specified in a tag File, the container creates a page-scoped attribute with the same name.

18. Which is valid tag files?
a. <jsp::dpBody/>
b. <jsp:invoke fragement="frag"/>
c. <%@page imports="java.util.Date">
d. <%@variable name-given ="date" variable-class="java.utilDate" %>
e. <%@ attribute name="name" value="blank" type="java.lang.String" %>

Ans: a, b, d

19. Which returns the enclosing tag when called from within a tag handler class?

a. getParent();
b. getAncestor();
c. findAncestor();
d. getEnclosingTag()

Ans : a

20. Given a web applications tructure

which tags could be used by an appropriate taglib directive?

a. Tag1.tag
b. Tag2.tag
c. Tag3.tag
d. Tag4.tag

Ans: Tag1.tag and Tag2.tag

JSP Interview / Practicer Questions

1. TLD files may be placed in any sub directory of -------


2. Assuming the standard JSTL prefix conventions are used, which JSTL tags would be used to iterate over collection of objects?
A. <x:forEach>
B. <c:iterate>
c. <c:forEach>
d. <c:forTokens>
e. <logic:iterates>
f. <logic:forEach>

Ans: <c:forEach>

3. <x:forEach> used for iterating over --------expressions.

Ans: XPath

4. <c:forTokens> used for iterating over --------- within a single string.

Ans : tokens

5. Which simple tag mechanism will tell a JSO page to stop processing?

a. Return SKIP_PAGE from the doTag method
b. Return SKIP_PAGE from the doEndTag method
c. Throw a SkipPageException from the doTag method
d. Throw a SKipPageException from doEndTag method

Ans : Throw a SkipPageException from the doTag method

6. Which are true about the classic tag model?

a. The tag interface can only be used to create empty tags.
b. The SKIP_PAGE constant is a valid return value of the doEndTag method.
c. The EVAL_BODY_BUFFERED constant is a valid return value of the doAfterBody method
d. The Tag interface only provides two values for the return value of the doStartTag method: SKIP_BODY and EVAl_BODY.
e. There are three tag interfaces Tag, Iteration Tag, and BodayTag, but only two built_in base classes: TagSupport and


Ans: b and e.

7. Which about the findAncestorWit
hClass method are true?

a. It requires one parameter: A Class
b. It is a static method in the TagSupport class
c. It is a non-static method in the TagSupport class.
d. It is not defined by any of the standard JSP tag interfaces.
e. It requires two parameters : A tag and a class
f. It requires one parameter : A string representing the name of the taf to be found.
g. It requires two parameters : A Tag and a String , representing the name of the tag to be found.

Ans: b, d and e

8. Which must be true if you want to use dynamic attributes for a simple tag handler?

a. Your simple tag must not declare any static tag attributes
b. Your simple tag must use the element in the TLD.
c. Your simple tag handler must implement the DynamicAttributes interface

Ans: b and c

9. Which is true about tag files?

a. A tag file may be placed in any subdirectory of WEb_INF
b. A tag file must
have the file extension of .tag and .tags

Ans : b

10 which about doAfterBody() is true?

a. doAfterBody() is only called on tags that extend TagSupport.
b. doAfterBody() is only called on tags that extend Iteration TagSupport
c. Assuming no exceptions occur, doAfterBody() is called after doStartTag(0 for any tag that implements Iteration Tag and

returns EVAL_BODY_INCLUDE from doStarttag()

Ans: c


WinSCP is free sftp client / scp client / ftp client for windows. It helps to transfer files between local and remote servers. The remote server can be window or linux or unix box.

Its main advantage is :

* It have explorer
* Windows like drag and drop options
* one side local and other side remote computer file manager
* If required stored the session information
* Integrated text editor
* Can perform all common operations with files.

You can download from

htmldoc : Convert Html file to PDF

htmldoc helps to convert the hyper-text markup language files and webpages to PDF, postscript files.

How to use this in Unix / Linux

1. Download htmldoc and install it in unix / linux system.
2. Get ready with input html / web page file
3. Use command
htmldoc/bin/htmldoc_path --landscape --top --right 0 left 7mm --bottom --fontsize 10.0 --webpage -f outputfilename inputfilename

To use this in perl running in linux / unix box

Just pass on parameters and execute this command using system command in perl

You can download this from

Linux / Unix - cut command

The cut command helps to cut the selected position/fields from given input/input file.

It have various options
-b - To cut from selected position. To start cut from given byte.
-f - To cut the given field.
-d - used for delimiter
-c - To cut the characters from given character position.

Extract the character positions

Tue Aug 14 16:58:43 EST 2012

$ date | cut -c1-3

$ date | cut -c5-7

$ date | cut -c1,2

Extact the specified fields
$ date | cut -f1,3 -d " "
Tue 14

$date | cut -f1-3 -d " "
Tue Aug 14

Extract the specified bytes
$ date | cut -b1-3

$ date | cut -b1,3

HG - Mercurial - How to tag the repository latest changeset

hg clone repository_url/project
cd project
hg tag V1.2
hg commit
hg push

Syndicate content