Thursday, January 27, 2011

The Interpersonal Communication Skills

Ability to ask the questions and listen are vital to the good interpersonal skills. In fact the empathetic listening is a number one skill which can help to build the relationships.

Ten Tips for Good Interpersonal Skills

*

Listen to the person first. Communication is the two-way process; getting all your message across depends on understanding a other person.
*

Be interested in people you will be communicating with. Remember that the people are more attracted towards those who have interest in them, and therefore will pay more attention to what they will say.
*

Relax. The bad body language like hunched shoulders, fidgeting, the toe-tapping or the hair-twiddling all give a game away.
*

Smile and use the eye contact. It is a most positive signal which you can give.
*

Ask the questions. It is great way to show the people that you really are interested in them.
*

If the other person has different point of view towards you find out why they have such point of view. More you understand reasons behind their thinking more you will be able to understand their point of view or can help them understand your point of view.
*

Be assertive. so that we can try to value their input as your own inputs. Do not be pushy and do not be a pushover. Try for a right balance.
*

When you will be speaking try to be enthusiastic in appropriate context. Use voice and the body language to show this.
*

Immediately don't try to latch to something which someone has just now said ... "oh yes it happened to me" and immediately go on and telling your own story. Make sure that you ask questions about them first and then be careful while telling your story so as not to sound like a competition.
*

Learn from the interactions. If you have a good conversation with someone try to think why it all went well and remember key points for the next time. If it did not go well - again try and learn something out of it.

Six Tips for More Effective Business Communication

The Internet has made it both easier and more difficult for people to communicate. It is now easier than ever to send written correspondence; all it takes is the click of a button. But many people would rather send off a quick email than pick up the phone, which means more people than ever are putting even their quick, casual business communication in writing. If writing is not your strong point, you may not be communicating with coworkers, clients, and partners as effectively as you could be. Here are six tips to make your business communication skills better.

Never hit the send button right after writing. Even if you are not writing an emotionally charged email, hitting send too fast can hurt you. You might have sounded a little more harsh than you meant to, or you might not have written as clearly as you could have. Either way, give it an hour or two and come back to it with fresh eyes before sending. Often you are too close to the material just after you have written it to spot flaws in your communication.

Tone it down. You may not mean to come off harshly, but people are always taking your emails and memos the wrong way. If this happens to you, you may not realize how harsh you sound in your writing. Sometimes when people read something negative, it blocks them from absorbing your entire message. Before sending out your email, read it over carefully to make sure your message is not too negative.

Write in Microsoft Word first. Microsoft Word has the Spell Check feature, and your email probably does not. The feature does not catch every mistake, but it may help you spot some typos that you otherwise would have missed. If you have difficulty with spelling, write your communications in Microsoft Word first to take advantage of its Spell Check feature.

Break it up. People have difficulty absorbing long unbroken blocks of text. To make your emails and other communications more reader-friendly, break them up into shorter paragraphs, each containing a single main idea. This will make it easier for readers to understand your point.

Don't be too casual. The Internet has given rise to a lot of casual acronyms and shortenings of words, such as your for your and u for you. Avoid these at all costs in business communications. They are too casual for a business environment.

Consider your audience. Are you writing to a marketing exec, a programmer or other technical employee, or the company president? Are you writing to one specific person or to a large audience with different levels of technical understanding? You should always tailor your communications to your audience. If you are writing to employees who are not technical, avoid specialized technical words and break concepts down so that laypeople can understand.

Every email and communication you send does not have to be a work of genius. But it does need to be easily understood. Use these tips, and your business communication is sure to improve.

by Jennifer Williamson

Jennifer Williamson runs a successful article writing business as a freelance writer in southern Pennsylvania.

Business Communication Etiquette

Many offices adopted a "business casual" attire in the workplace in the 1990's. This meant a more relaxed attire - no more suits, ties, panty hose, and so forth. Unfortunately, many business people have also adopted a business casual attitude in their business communications.

Everyone could benefit from a lesson (or two!) in "netiquette" - or how to communicate professionally in a business environment using tools such as e-mail, instant message programs, text messaging and so forth.

Technology has made communicating a very different medium than it was just five years ago. We're all so busy that we dash off quick messages, sometimes totally forgetting to use proper grammar, punctuation and spelling. While this is acceptable for friends, it is not acceptable in a professional environment.

E-mail is often the first communication that one has with a potential client or business associate. It is still very true that first impressions are the most important. If you had a meeting with someone whose clothes were dirty and torn, had messy hair and provided you with inaccurate product information, you probably wouldn't end up doing business with them. Yet, every day, this same "unkemptness" appears in business communications.

Take this example: "Per ur request, i'm sending our current info. IMHO, we have the best produce in the mkt." Gee, I'd really want to do business with this person, wouldn't you - and are they selling fruits and vegetables, or did they misspell product?

Spelling, punctuation and grammar do count. Most e-mail programs have the ability to check these items. The little squiggly underlines are not there for fun! They are pointing out an error. Don't ignore them. Also, don't be in such a hurry to send your message that you don't quickly re-read it. (Don't get me started on people who send text messages while driving!) Once you hit "send" there is no way to correct your message, so take the time to make sure it's truly what you want to say before sending it.

While you may think you're being funny, remember that there is absolutely no way for the recipient to know the "tone" that you intended for your message. You may think you're being brief and succinct, while they will think you're being curt and impolite. Of course, many people now use "emoticons" to try to convey emotions. Sending a smiley or winking face is OK when the recipient is your friend; however, it's not OK when you're communicating with a CEO. After all, you wouldn't send a hand-written note to a CEO with all of the "dots" in your "i's" as smiley faces or hearts, would you?

The only thing worse than emoticons is "Internet slang" - that is, the abbreviation of many words. While practically everyone knows what "FYI" means, what about AFAIK and NOOB? Just as you shouldn't use an acronym unless you are absolutely certain the recipient knows what you mean, don't use Internet slang either.

When we communicated with our friends when we were young, we wrote: "How are you? I am fine." We've all forgotten this basic politeness. While we don't want to be this simple, it is much better to say: "It was a pleasure meeting you yesterday. I enjoyed learning about your business and as you requested, I am sending you our current product information. I'll follow-up with you in a couple of days to answer any questions you may have." Unfortunately, in our fast-paced business world, the more typical communication is along the lines of: "Here's the info. Call me if you have questions." While both say essentially the same thing, who would you rather do business with - especially if this was the first communication you had with the person about their company and their product?

When you really want to impress someone, the best way is to take the time to write them an actual note or letter that you put in an envelope, put a stamp on and mail, rather than dashing off a quick e-mail. It doesn't matter that your penmanship may not be perfect. What's important is that you actually took the time to send them a personalized communication. We all loved getting cards and letters when we were young and I believe the same is true today. Aside from anything else, a personal communication sets you apart from everyone else who just sends e-mails and quick text messages!

No matter what form of communication you use, remember that when you take the time to make sure it is correct, you are showing a certain level of respect for your recipient. How important are they to you - and your business?

FYI - AFAIK means "as far as I know" and NOOB means "someone who is new."

by Deborah Krier

Deborah Krier, president and founder of Wise Women Communications, is a marketing and public relations professional with experience in media and public relations, internal and external communication, crisis management, integrated marketing campaigns, brand management, event coordination, Web site design and development, and community relations. She managed corporate communications programs for the Denver site of ING Group, served as a media and communications coordinator for the Rocky Mountain Region of the American Cancer Society, served as the director of public relations and account manager for Linnell & Soreide Marketing Partners, a full-service marketing and advertising firm. In addition, she provided lobbying support at a state and local level for Corporate Advocates, a Denver-based firm. Deborah holds an MBA degree with an emphasis in marketing from the University of Colorado and an MS degree in communications management from Colorado State University.

JSP Interview Questions and Answers

What is a JSP and what is it used for?
Java Server Pages (JSP) is a platform independent presentation layer technology that comes with SUN s J2EE platform. JSPs are normal HTML pages with Java code pieces embedded in them. JSP pages are saved to *.jsp files. A JSP compiler is used in the background to generate a Servlet from the JSP page.

What is difference between custom JSP tags and beans?
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:
1. the tag handler class that defines the tag\'s behavior
2. the tag library descriptor file that maps the XML element names to the tag implementations
3. the JSP file that uses the tag library
When the first two components are done, you can use the tag by using taglib directive:
<%@ taglib uri="xxx.tld" prefix="..." %>
Then you are ready to use the tags you defined. Let's say the tag prefix is test:
MyJSPTag or
JavaBeans are Java utility classes you defined. Beans have a standard format for Java classes. You use tags to declare a bean and use to set value of the bean class and use to get value of the bean class.

<%=identifier.getclassField() %>
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.

What are the two kinds of comments in JSP and what's the difference between them ?
<%-- JSP Comment --%>


What is JSP technology?

Java Server Page is a standard Java extension that is defined on top of the servlet Extensions. The goal of JSP is the simplified creation and management of dynamic Web pages. JSPs are secure, platform-independent, and best of all, make use of Java as a server-side scripting language.

What is JSP page?
A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format such as HTML, SVG, WML, and XML, and JSP elements, which construct dynamic content.

What are the implicit objects?
Implicit objects are objects that are created by the web container and contain information related to a particular request, page, or application. They are:
--request
--response
--pageContext
--session
--application
--out
--config
--page
--exception

How many JSP scripting elements and what are they?
There are three scripting language elements:
--declarations
--scriptlets
--expressions

Why are JSP pages the preferred API for creating a web-based client program?
Because no plug-ins or security policy files are needed on the client systems(applet does). Also, JSP pages enable cleaner and more module application design because they provide a way to separate applications programming from web page design. This means personnel involved in web page design do not need to understand Java programming language syntax to do their jobs.

Is JSP technology extensible?
YES. JSP technology is extensible through the development of custom actions, or tags, which are encapsulated in tag libraries.

Can we use the constructor, instead of init(), to initialize servlet?
Yes , of course you can use the constructor instead of init(). There’s nothing to stop you. But you shouldn’t. 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 constructur 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.

How can a servlet refresh automatically if some new data has entered the database?
You can use a client-side Refresh or Server Push.

The code in a finally clause will never fail to execute, right?
Using System.exit(1); in try block will not allow finally code to execute.

How many messaging models do JMS provide for and what are they?
JMS provide for two messaging models, publish-and-subscribe and point-to-point queuing.

What information is needed to create a TCP Socket?
The Local Systems IP Address and Port Number. And the Remote System’s IPAddress and Port Number.

What Class.forName will do while loading drivers?
It is used to create an instance of a driver and register it with the DriverManager. When you have loaded a driver, it is available for making a connection with a DBMS.

How to Retrieve Warnings?
SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an application, as exceptions do; they simply alert the user that something did not happen as planned. A warning can be reported on a Connection object, a Statement object (including PreparedStatement and CallableStatement objects), or a ResultSet object. Each of these classes has a getWarnings method, which you must invoke in order to see the first warning reported on the calling object

SQLWarning warning = stmt.getWarnings();
if (warning != null)
{
while (warning != null)
{
System.out.println(\"Message: \" + warning.getMessage());
System.out.println(\"SQLState: \" + warning.getSQLState());
System.out.print(\"Vendor error code: \");
System.out.println(warning.getErrorCode());
warning = warning.getNextWarning();
}
}

How many JSP scripting elements are there and what are they?
There are three scripting language elements: declarations, scriptlets, expressions.

In the Servlet 2.4 specification SingleThreadModel has been deprecated, why?

Because it is not practical to have such model. Whether you set isThreadSafe to true or false, you should take care of concurrent client requests to the JSP page by synchronizing access to any shared objects defined at the page level.

What are stored procedures? How is it useful?
A stored procedure is a set of statements/commands which reside in the database. The stored procedure is pre-compiled and saves the database the effort of parsing and compiling sql statements every time a query is run. Each database has its own stored procedure language, usually a variant of C with a SQL preproceesor. Newer versions of db’s support writing stored procedures in Java and Perl too. Before the advent of 3-tier/n-tier architecture it was pretty common for stored procs to implement the business logic( A lot of systems still do it). The biggest advantage is of course speed. Also certain kind of data manipulations are not achieved in SQL. Stored procs provide a mechanism to do these manipulations. Stored procs are also useful when you want to do Batch updates/exports/houseKeeping kind of stuff on the db. The overhead of a JDBC Connection may be significant in these cases.

How do I include static files within a JSP page?
Static resources should always be included using the JSP include directive. This way, the inclusion is performed just once during the translation phase. Do note that you should always supply a relative URL for the file attribute. Although you can also include static resources using the action, this is not advisable as the inclusion is then performed for each and every request.

Why does JComponent have add() and remove() methods but Component does not?
because JComponent is a subclass of Container, and can contain other components and jcomponents. How can I implement a thread-safe JSP page? - You can make your JSPs thread-safe by having them implement the SingleThreadModel interface. This is done by adding the directive <%@ page isThreadSafe="false" % > within your JSP page.

How do I prevent the output of my JSP or Servlet pages from being cached by the browser?
You will need to set the appropriate HTTP header attributes to prevent the dynamic content output by the JSP page from being cached by the browser. Just execute the following scriptlet at the beginning of your JSP pages to prevent them from being cached at the browser. You need both the statements to take care of some of the older browser versions.

How do you restrict page errors display in the JSP page?
You first set "Errorpage" attribute of PAGE directory to the name of the error page (ie Errorpage="error.jsp")in your jsp page .Then in the error jsp page set "isErrorpage=TRUE". When an error occur in your jsp page it will automatically call the error page.

How can I enable session tracking for JSP pages if the browser has disabled cookies?
We know that session tracking uses cookies by default to associate a session identifier with a unique user. If the browser does not support cookies, or if cookies are disabled, you can still enable session tracking using URL rewriting. URL rewriting essentially includes the session ID within the link itself as a name/value pair.
However, for this to be effective, you need to append the session ID for each and every link that is part of your servlet response. Adding the session ID to a link is greatly simplified by means of of a couple of methods: response.encodeURL() associates a session ID with a given URL, and if you are using redirection, response.encodeRedirectURL() can be used by giving the redirected URL as input.
Both encodeURL() and encodeRedirectedURL() first determine whether cookies are supported by the browser; if so, the input URL is returned unchanged since the session ID will be persisted as a cookie. Consider the following example, in which two JSP files, say hello1.jsp and hello2.jsp, interact with each other.
Basically, we create a new session within hello1.jsp and place an object within this session. The user can then traverse to hello2.jsp by clicking on the link present within the page.Within hello2.jsp, we simply extract the object that was earlier placed in the session and display its contents. Notice that we invoke the encodeURL() within hello1.jsp on the link used to invoke hello2.jsp; if cookies are disabled, the session ID is automatically appended to the URL, allowing hello2.jsp to still retrieve the session object. Try this example first with cookies enabled. Then disable cookie support, restart the brower, and try again. Each time you should see the maintenance of the session across pages.
Do note that to get this example to work with cookies disabled at the browser, your JSP engine has to support URL rewriting.
hello1.jsp
hello2.jsp
hello2.jsp
<%
Integer i= (Integer )session.getValue("num");
out.println("Num value in session is "+i.intValue());

What JSP lifecycle methods can I override?
You cannot override the _jspService() method within a JSP page. You can however, override the jspInit() and jspDestroy() methods within a JSP page. jspInit() can be useful for allocating resources like database connections, network connections, and so forth for the JSP page. It is good programming practice to free any allocated resources within jspDestroy().
The jspInit() and jspDestroy() methods are each executed just once during the lifecycle of a JSP page and are typically declared as JSP declarations:

How do I perform browser redirection from a JSP page?
You can use the response implicit object to redirect the browser to a different resource, as:
response.sendRedirect("http://www.exforsys.com/path/error.html");
You can also physically alter the Location HTTP header attribute, as shown below:
You can also use the:
Also note that you can only use this before any output has been sent to the client. I beleve this is the case with the response.sendRedirect() method as well. If you want to pass any paramateres then you can pass using >

How does JSP handle run-time exceptions?
You can use the errorPage attribute of the page directive to have uncaught runtime exceptions automatically forwarded to an error processing page.
For example:
redirects the browser to the JSP page error.jsp if an uncaught exception is encountered during request processing. Within error.jsp, if you indicate that it is an error-processing page, via the directive:
the Throwable object describing the exception may be accessed within the error page via the exception implicit object.
Note: You must always use a relative URL as the value for the errorPage attribute.

How do I use comments within a JSP page?
You can use "JSP-style" comments to selectively block out code while debugging or simply to comment your scriptlets. JSP comments are not visible at the client.
For example:
--%>
You can also use HTML-style comments anywhere within your JSP page. These comments are visible at the client. For example:
Of course, you can also use comments supported by your JSP scripting language within your scriptlets.

Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?
You can pass the HttpSession as parameter to an EJB method, only if all objects in session are serializable. This has to be consider as "passed-by-value", that means that it's read-only in the EJB.
If anything is altered from inside the EJB, it won't be reflected back to the HttpSession of the Servlet Container.The "pass-byreference" can be used between EJBs Remote Interfaces, as they are remote references.
While it IS possible to pass an HttpSession as a parameter to an EJB object, it is considered to be "bad practice" in terms of object oriented design. This is because you are creating an unnecessary coupling between back-end objects (ejbs) and front-end objects (HttpSession). Create a higher-level of abstraction for your ejb's api. Rather than passing the whole, fat, HttpSession (which carries with it a bunch of http semantics), create a class that acts as a value object (or structure) that holds all the data you need to pass back and forth between front-end/back-end.
Consider the case where your ejb needs to support a non-http-based client. This higher level of abstraction will be flexible enough to support it.

How can I implement a thread-safe JSP page?
You can make your JSPs thread-safe by having them implement the SingleThreadModel interface. This is done by adding the directive <%@ page isThreadSafe="false" % > within your JSP page.

How can I declare methods within my JSP page?
You can declare methods for use within your JSP page as declarations. The methods can then be invoked within any other methods you declare, or within JSP scriptlets and expressions.
Do note that you do not have direct access to any of the JSP implicit objects like request, response, session and so forth from within JSP methods. However, you should be able to pass any of the implicit JSP variables as parameters to the methods you declare.
For example:
Another Example:
file1.jsp:
file2.jsp
<%test(out);% >

Can I stop JSP execution while in the midst of processing a request?
Yes. Preemptive termination of request processing on an error condition is a good way to maximize the throughput of a high-volume JSP engine. The trick (assuming Java is your scripting language) is to use the return statement when you want to terminate further processing.

Can a JSP page process HTML FORM data?
Yes. However, unlike Servlet, you are not required to implement HTTP-protocol specific methods like doGet() or doPost() within your JSP page. You can obtain the data for the FORM input elements via the request implicit object within a scriptlet or expression as.

Is there a way to reference the "this" variable within a JSP page?
Yes, there is. Under JSP 1.0, the page implicit object is equivalent to "this", and returns a reference to the Servlet generated by the JSP page.

How do you pass control from one JSP page to another?
Use the following ways to pass control of a request from one servlet to another or one jsp to another.
The RequestDispatcher object ‘s forward method to pass the control.
The response.sendRedirect method

Is there a way I can set the inactivity lease period on a per-session basis?
Typically, a default inactivity lease period for all sessions is set within your JSPengine admin screen or associated properties file. However, if your JSP engine supports the Servlet 2.1 API, you can manage the inactivity lease period on a per-session basis.
This is done by invoking the HttpSession.setMaxInactiveInterval() method, right after the session has been created.

How does a servlet communicate with a JSP page?
The following code snippet shows how a servlet instantiates a bean and initializes it with FORM data posted by a browser. The bean is then placed into the request, and the call is then forwarded to the JSP page, Bean1.jsp, by means of a request dispatcher for downstream processing.
public void doPost (HttpServletRequest request, HttpServletResponse response)
{
try {
govi.FormBean f = new govi.FormBean();
String id = request.getParameter("id");
f.setName(request.getParameter("name"));
f.setAddr(request.getParameter("addr"));
f.setAge(request.getParameter("age"));

//use the id to compute
//additional bean properties like info
//maybe perform a db query, etc.
// . . .

f.setPersonalizationInfo(info);
request.setAttribute("fBean",f);
getServletConfig().getServletContext().getRequestDispatcher
("/jsp/Bean1.jsp").forward(request, response);
} catch (Exception ex) {
. . .
}
}

The JSP page Bean1.jsp can then process fBean, a
fter first extracting it from the default request
scope via the useBean action.

jsp:useBean id="fBean" class="govi.FormBean" scope="request"/ jsp:getProperty
name="fBean" property="name" / jsp:getProperty name="fBean" property="addr"
/ jsp:getProperty name="fBean" property="age" / jsp:getProperty name="fBean"
property="personalizationInfo" /

Can you make use of a ServletOutputStream object from within a JSP page?
No. You are supposed to make use of only a JSPWriter object (given to you in the form of the implicit object out) for replying to clients.
A JSPWriter can be viewed as a buffered version of the stream object returned by response.getWriter(), although from an implementational perspective, it is not.
A page author can always disable the default buffering for any page using a page directive as:

How do I include static files within a JSP page?
Static resources should always be included using the JSP include directive. This way, the inclusion is performed just once during the translation phase.
The following example shows the syntax:
< % @ include file="copyright.html" % >
Do note that you should always supply a relative URL for the file attribute. Although you can also include static resources using the action, this is not advisable as the inclusion is then performed for each and every request.
How do I have the JSP-generated servlet subclass my own custom servlet class, instead of the default? One should be very careful when having JSP pages extend custom servlet classes as opposed to the default one generated by the JSP engine. In doing so, you may lose out on any advanced optimization that may be provided by the JSPengine.
In any case, your new super class has to fulfill the contract with the JSP engine by: Implementing the HttpJspPage interface, if the protocol used is HTTP, or implementing JspPage otherwise Ensuring that all the methods in the Servlet interface are declared final.
Additionally, your servlet super class also needs to do the following:
The service() method has to invoke the _jspService() method
The init() method has to invoke the jspInit() method
The destroy() method has to invoke jspDestroy()
If any of the above conditions are not satisfied, the JSP engine may throw a translation error. Once the super class has been developed, you can have your JSP extend it as follows:

Can a JSP page instantiate a serialized bean?
No problem! The use Bean action specifies the beanName attribute, which can be used for indicating a serialized bean.
For example:
A couple of important points to note. Although you would have to name your serialized file "filename.ser", you only indicate "filename" as the value for the beanName attribute. Also, you will have to place your serialized file within the WEB-INFjspbeans directory for it to be located by the JSP engine.

What is JSP?
Let's consider the answer to that from two different perspectives: that of an HTML designer and that of a Java programmer.
If you are an HTML designer, you can look at JSP technology as extending HTML to provide you with the ability to seamlessly embed snippets of Java code within your HTML pages. These bits of Java code generate dynamic content, which is embedded within the other HTML/XML content you author. Even better, JSP technology provides the means by which programmers can create new HTML/XML tags and JavaBeans components, which provide new features for HTML designers without those designers needing to learn how to program.
Note: A common misconception is that Java code embedded in a JSP page is transmitted with the HTML and executed by the user agent (such as a browser). This is not the case. A JSP page is translated into a Java servlet and executed on the server. JSP statements embedded in the JSP page become part of the servlet generated from the JSP page. The resulting servlet is executed on the server. It is never visible to the user agent.
If you are a Java programmer, you can look at JSP technology as a new, higher-level means to writing servlets. Instead of directly writing servlet classes and then emitting HTML from your servlets, you write HTML pages with Java code embedded in them. The JSP environment takes your page and dynamically compiles it. Whenever a user agent requests that page from the Web server, the servlet that was generated from your JSP code is executed, and the results are returned to the user.

How do I mix JSP and SSI #include?
Answer 1
If you're just including raw HTML, use the #include directive as usual inside your .jsp file.
But it's a little trickier if you want the server to evaluate any JSP code that's inside the included file. If your data.inc file contains jsp code you will have to use
The is used for including non-JSP files.
Answer 2
If you're just including raw HTML, use the #include directive as usual inside your .jsp file.

But it's a little trickier if you want the server to evaluate any JSP code that's inside the included file. Ronel Sumibcay (ronel@LIVESOFTWARE.COM) says: If your data.inc file contains jsp code you will have to use
<%@ vinclude="data.inc" %>
The is used for including non-JSP files.

How do I mix JSP and SSI #include? What is the difference between include directive & jsp:include action?
Difference between include directive and
1. provides the benefits of automatic recompliation,smaller class size ,since the code corresponding to the included page is not present in the servlet for every included jsp page and option of specifying the additional request parameter.
2.The also supports the use of request time attributes values for dynamically specifying included page which directive does not.
3.the include directive can only incorporate contents from a static document.
4. can be used to include dynamically generated output e.g.. from servlets.
5.include directive offers the option of sharing local variables, better run time efficiency.
6.Because the include directive is processed during translation and compilation, it does not impose any restrictions on output buffering.

How do you prevent the Creation of a Session in a JSP Page and why? What is the difference between include directive & jsp:include action?
By default, a JSP page will automatically create a session for the request if one does not exist.
However, sessions consume resources and if it is not necessary to maintain a session, one should not be created. For example, a marketing campaign may suggest the reader visit a web page for more information. If it is anticipated that a lot of traffic will hit that page, you may want to optimize the load on the machine by not creating useless sessions.

How do I use a scriptlet to initialize a newly instantiated bean?
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. 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.
The following example shows the "today" property of the Foo bean initialized to the current date when it is instantiated. Note that here, we make use of a JSP expression within the jsp:setProperty action.
value=""/ >

How can I set a cookie and delete a cookie from within a JSP page?
A cookie, mycookie, can be deleted using the following scriptlet:

How do you connect to the database from JSP?
A Connection to a database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets.
Further then you can use the resultset object "res" to read data in the following way.

What is the page directive is used to prevent a JSP page from automatically creating a session?
<%@ page session="false">

How do you delete a Cookie within a JSP?
Cookie mycook = new Cookie("name","value");
response.addCookie(mycook);
Cookie killmycook = new Cookie("mycook","value");
killmycook.setMaxAge(0);
killmycook.setPath("/");
killmycook.addCookie(killmycook);

Can we implement an interface in a JSP?
No

What is the difference between ServletContext and PageContext?
ServletContext: Gives the information about the container
PageContext: Gives the information about the Request

What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?
request.getRequestDispatcher(path): In order to create it we need to give the relative path of the resource context.getRequestDispatcher(path): In order to create it we need to give the absolute path of the resource.

How to pass information from JSP to included JSP?
Using <%jsp:param> tag.

How is JSP include directive different from JSP include action. ?
When a JSP include directive is used, the included file's code is added into the added JSP page at page translation time, this happens before the JSP page is translated into a servlet. While if any page is included using action tag, the page's output is returned back to the added page. This happens at runtime.

Can we override the jspInit(), _jspService() and jspDestroy() methods?
We can override jspinit() and jspDestroy() methods but not _jspService().

Why is _jspService() method starting with an '_' while other life cycle methods do not?
_jspService() method will be written by the container hence any methods which are not to be overridden by the end user are typically written starting with an '_'. This is the reason why we don't override _jspService() method in any JSP page.

What happens when a page is statically included in another JSP page?
An include directive tells the JSP engine to include the contents of another file (HTML, JSP, etc.) in the current page. This process of including a file is also called as static include.

A JSP page, include.jsp, has a instance variable "int a", now this page is statically included in another JSP page, index.jsp, which has a instance variable "int a" declared. What happens when the index.jsp page is requested by the client?
Compilation error, as two variables with same name can't be declared. This happens because, when a page is included statically, entire code of included page becomes part of the new page. at this time there are two declarations of variable 'a'. Hence compilation error.

Can you override jspInit() method? If yes, In which cases?
ye, we can. We do it usually when we need to initialize any members which are to be available for a servlet/JSP throughout its lifetime.

What is the difference between directive include and jsp include?
<%@ include> : Used to include static resources during translation time. : Used to include dynamic content or static content during runtime.

What is the difference between RequestDispatcher and sendRedirect?
RequestDispatcher: server-side redirect with request and response objects. sendRedirect : Client-side redirect with new request and response objects.

How does JSP handle runtime exceptions?
Using errorPage attribute of page directive and also we need to specify isErrorPage=true if the current page is intended to URL redirecting of a JSP.

How can my application get to know when a HttpSession is removed?
Define a Class HttpSessionNotifier which implements HttpSessionBindingListener and implement the functionality what you need in valueUnbound() method.
Create an instance of that class and put that instance in HttpSession.

What Class.forName will do while loading drivers?
It is used to create an instance of a driver and register it with the DriverManager. When you have loaded a driver, it is available for making a connection with a DBMS.

How to Retrieve Warnings?
SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an application, as exceptions do; they simply alert the user that something did not happen as planned. A warning can be reported on a Connection object, a Statement object (including PreparedStatement and CallableStatement objects), or a ResultSet object. Each of these classes has a getWarnings method, which you must invoke in order to see the first warning reported on the calling object

SQLWarning warning = stmt.getWarnings();
if (warning != null)
{
while (warning != null)
{
System.out.println(\"Message: \" + warning.getMessage());
System.out.println(\"SQLState: \" + warning.getSQLState());
System.out.print(\"Vendor error code: \");
System.out.println(warning.getErrorCode());
warning = warning.getNextWarning();
}
}

How many JSP scripting elements are there and what are they?
There are three scripting language elements: declarations, scriptlets, expressions.

In the Servlet 2.4 specification SingleThreadModel has been deprecated, why?
Because it is not practical to have such model. Whether you set isThreadSafe to true or false, you should take care of concurrent client requests to the JSP page by synchronizing access to any shared objects defined at the page level.

Is JSP technology extensible?
YES. JSP technology is extensible through the development of custom actions, or tags, which are encapsulated in tag libraries.

Can we use the constructor, instead of init(), to initialize servlet?
Yes , of course you can use the constructor instead of init(). There’s nothing to stop you. But you shouldn’t. 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 constructur 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.

How can a servlet refresh automatically if some new data has entered the database?
You can use a client-side Refresh or Server Push.

The code in a finally clause will never fail to execute, right?
Using System.exit(1); in try block will not allow finally code to execute.

How many messaging models do JMS provide for and what are they?
JMS provide for two messaging models, publish-and-subscribe and point-to-point queuing.

ASP Interview Questions and Answers

What is ASP?
ASP stands for Active Server Pages. It is a server side technology which is used to display dynamic content on web pages. For example you could write code that would give your visitors different information, different images or even a totally different page depending on what browser version they are using.

How can you disable the browser to view the code?
Writing codes within the Tag

What is a "Virtual Directory"?
Virtual directories are aliases for directory paths on the server. It allows moving files on the disk between different folders, drives or even servers without changing the structure of web pages. It avoids typing an extremely long URL each time to access an ASP page.

Give the comment Tags for the following?
VBScript : REM & ‘(apostrophe)
JavaScript : // (single line comment)
/* */ (Multi-line comments)

Which is the default Scripting Language of ASP (server-side)?

VBScript

Which is the default Data types in VBScript?
Variant is the default data type in VBScript, which can store a value of any type.

What is a variable?
Variable is a memory location through which the actual values are stored/retrieved. Its value can be changed.

What is the maximum size of an array?
Up to 60 dimensions.

What is Query string collection?
This collection stores any values that are provided in the URL. This can be generated by three methods:
By clicking on an anchor tag
By sending a form to the server by the GET method
Through user-typed HTTP address

It allows you to extract data sent to the server using a GET request.

What are the attributes of the tags? What are their functions?
The two attributes are ACTION and METHOD
The ACTION gives the name of the ASP file that should be opened next by which this file can access the information given in the form The METHOD determines which of the two ways (POST or GET) the browser can send the information to the server

What are the methods in Session Object?
The Session Object has only one method, which is Abandon. It destroys all the objects stored in a Session Object and releases the server resources they occupied.

What is ServerVariables collection?
The ServerVariables collection holds the entire HTTP headers and also additional items of information about the server.

What is the difference between Querystring collection and Form collection?
The main difference is that the Querystring collection gets appended to a URL.

What is a Form collection?
The Form collection holds the values of the form elements submitted with the POST method. This is the only way to generate a Form collection.

What are the ASP Scripting Objects?
The Dictionary object, the FileSystemObject object, TextStream object.

What happens to a HTML page?
The browser makes a HTTP request; the server gives a HTTP response to the browser and the browser converts into a HTML page.

What happens to ASP pages?
The browser makes a HTTP request; the server does the processing and gives a HTML response to the browser.

How can you change the primary scripting language for a page?
Specify

What is application Object?
Shares information among users of an application. Gives a notification when an application starts or ends.

What is the difference between client-side script and server-side script?
Scripts executed only by the browser without contacting the server is called client-side script. It is browser dependent. The scripting code is visible to the user and hence not secure. Scripts executed by the web server and processed by the server is called server-side script.

What is the command to display characters to the HTML page?
Response.Write

Explain the POST & GET Method or Explain the difference between them?
POST METHOD:
The POST method generates a FORM collection, which is sent as a HTTP request body. All the values typed in the form will be stored in the FORM collection.
GET METHOD:
The GET method sends information by appending it to the URL (with a question mark) and stored as A Querystring collection. The Querystring collection is passed to the server as name/value pair.
The length of the URL should be less than 255 characters.

How many global.asa files can an Application have?

Only one global.asa file and it’s placed in the virtual directory’s root.

What are Scripting Objects?
Objects that can enhance the application are known as the Scripting Objects.

What is the Order of precedence for LOGICAL Operators ?
NOT, AND, OR, XOR, EQV, IMP

What is an Err Object?
Name it’s properties and methods.

What are LOCAL and GLOBAL variables?
Local variables lifetime ends when the Procedure ends. Global variables lifetime begins at the start of the script and ends at the end of the script and it can be used by any procedure within the script. Declaring a variable by using the keyword PRIVATE makes the variable global within the script, but if declared using PUBLIC, then all scripts can refer the variable.

Which is the default Scripting Language on the client side?
JavaScript

What is HTML (Hypertext Markup Language)?
It’s a method by which web pages can be built and generally used for formatting and linking text.

What is a Web Server?
It’s a Computer that provides Web services on the Internet or on a local Intranet. It is designed to locate, address and send out simple HTML pages to all other users who access these pages.

What is Session Object?
It stores information about a User’s session. Gives a notification when a user session begins or ends.

What is Server-Side includes?
It provides extra information by which it makes the site easier to manage. It can include text files using the #include statement, retrieve the size and last modification date of a file, defines how variables and error messages are displayed and inserts the values of HTTP variables in the page sent back to the browser.

What is a FileSystemObject object?
It provides access to the physical file system of the web server. It gets and manipulates information about all drives in a server, folders and sub-folders on a drive and files inside a folder.

What is a Scripting Language?
It permits to create more interactive Web Pages. Validation, formatting of web pages can be done. VBScript, JavaScript are some examples.

What is a Dictionary object?
It lets you store and retrieve information in a flexible data structure. Each value or information stored in a Dictionary is associated with a key through which the information can be retrieved.

What is Global.asa file?
It is text file that contains details about an ASP application, such as when it should begin and end.

What is an .ASP file?
It is a Text File that contains the combination of the following:
Text
HTML tags
Script Commands

What is Response Object?
It controls the information sent to the user. The various methods are:
Response.Write - Sends information directly to a browser
Response.Redirect - Directs a user to a URL other than the requested URL
Response.ContentType - Controls the type of content sent
Response.Cookies - Sets cookie values
Response.Buffer - To Buffer information

Naming constraints for a variable ?
It can be up to 255 characters Must start with an alphabet Must not contain an embedded period or full-stop

What is a TextStream object?
It allows you to access(read/write) the contents of text files stored on the web server.

What is IIS?
IIS is a Web Server that provides Web services, not only for web pages but also for ftp sites and video and audio services. It integrates with the database facilities of SQL Server.

What is Request Object?
Gets information from the user. It has five collections by which values can be accessed. They are: Query string, Form, Cookies, Server Variables & Client Certificate

What are the special sub-types in VBScript?
EMPTY: has no value
NULL: Value does not exist (conjunction with database)
OBJECT:

What is Cookies collection?
Cookies are text files that store information about the user by which the web server identifies and marks each different visitor to a web site and determines where a user has been before. A cookie can store information only when the user sends it. Individual cookies are limited to 4KB of data. The maximum number of cookies allowed is 300.
Cookies are stored on client’s machine.

What is the difference between Cookies collection and Form/Query string collection?
Cookie collection does not have the Count property. Cookies can have multiple values for the same cookie name but each value can be referred using a key whereas in a Form/Query string cookie each value has to be referred using an index value.

What is Server Object?
Controls the ASP execution environment. It can set the amount of time script can run before an error occurs. Converts a virtual path to a physical path on the server. Takes a user supplied string and encode it into proper format for a URL string.

What is Collection?
Collection is a set of name/value pairs where the information supplied by the client is stored.

How will you delete a Cookie?
By setting its Expires property to any date prior to today Response.Cookies("cookie name"). Expires = Date 1.

What is the function of Buffer in Response Object?
Buffer controls the HTML output stream manually.

How are scripts executed?
ASP provides scripting engines that execute the corresponding scripting languages on the server side. Scripts should be encoded within the Delimiters.

What is ASP (Active Server Pages)?
ASP is a server side-scripting environment for building dynamic and interactive web pages. Since the scripts run on the server side, the web server does all the processing.

What are ARRAYS?
Arrays are variables that store items of similar information.DIM ARRAY1(4) (declares an array with the name array1 with 5 elements)

What is Application-scope?
Application-scope means that variables (and objects) can be accessed from any ASP pages that is part of the application.

What is Extranet?
An area of a web site available only to a set of registered visitors.

< SCRIPT LANGUAGE="VBScript" RUNAT=Server >
a = 1
< /SCRIPT >
< SCRIPT LANGUAGE="VBScript" >
a = 2
< /SCRIPT >
< %
Response.Write a
% <
In the sample code shown above, what will be written to the screen?
A. 1
B. 2
C. 1, 2
D. 1&2
E. Nothing. (Answer)

< % iPos = Instr("Hello World","r") % <
Referring to the above, what is the value of iPos?
A. 0
B. 1
C. 2
D. 8
E. 9 (Answer)

What are the types of HTML?
Static HTML Browser uses HTTP to request HTML file from the Web Server
Dynamic HTML Browser uses HTTP to request an executable application rather than a Static HTML file

What are the properties of Session Object?
SessionID returns the session identification number for each user.
Timeout sets the timeout period assigned to the Session object for any application, in minutes.
CodePage determines the code page that will be used to display content.
LCID a locale identifier, which determines time zone and language, rules for the system

What are the event handlers of Session Object?
Session _OnStart This event will be fired when a new user begins a session with the web site.
Session_OnEnd This event is called whenever a session terminates.

Name the ASP Objects?
Request Object
Response Object
Server Object
Session Object
Application Object

What are the advantages of using ASP?
Minimizes network traffic by limiting the need for the browser and server to talk to each other
Makes for quicker loading time since HTML pages are only downloaded
Allows to run programs in languages that are not supported by the browser
Can provide the client with data that does not reside on the client’s machine
Provides improved security measures since the script cannot be viewed by the browser

What are the methods in Application Object?
Lock prevents clients from modifying the variables stored in the Application object.
Unlock removes the lock from variables stored in the Application object.

What are the methods in Application Object?
Internet Information Server (IIS) on Windows NT
Personal Web Server (PWS) on Windows 95
Peer Web Services on Windows NT

What are the browsers that can access ASP pages?
Internet Explorer (supports VBScript, JavaScript)
Netscape Communicator/ Navigator (supports only JavaScript, VBScript can be also added too)

How does the server identify and execute the server-side scripts within HTML code?
Including the RUNAT=SERVER attribute

What are the methods by which output stream is controlled?
Flush sends previous buffered output to the client immediately, but continues processing the script.
Clear erases any already-buffered HTML.
End causes the server to stop processing the script.

What are the properties used to control the expiration of the page?
Expires specifies the number of minutes before a page cached on a browser expires.
ExpiresAbsolute sets the date and time at which a page cached on a browser expires.

What are the collections of Session Object?
Contents collection contains all the variables established for a session without using the tag.
Static collection contains all the objects created

What is the difference between ASP and HTML? Or Why ASP is better than HTML?
- ASP executes code on the server side whereas the browser interprets HTML.
- ASP can use any scripting languages
- Gets feedback from the user and return information to the user
- Create pages that will be customized to display only things that will be of interest to a particular user
- Can edit contents of a web page by updating a text file or a database rather than the HTML code itself

What are the event handlers of Application Object?
Application_OnStart- This event will be fired when the first visitor hits the page.
Application_OnEnd- This event runs when the server is stopped.

Name some of the ASP components?
Ad Rotator component- a way to manage advertisements on the web site.
Content Linker component - a technique to direct users through a set of pages on a web site by creating a list of URLs and description of the next and previous pages.
Browser Capabilities component - allows to customize the page to the ability of the browser viewing it.
Database Access component - allows to access data from the database

What are the tasks performed by < FORM > tags?
tags provides space for the user to input values
the form has a button to submit information back to the server
It transfers control to another ASP page
It carries the information in the fields to another ASP page

What are the tags necessary to be present within the
tag?
-----tag: Provides input spaces (text boxes, combo boxes, radio button, etc.) on a form called fields. It has three attributes TYPE, NAME and VALUE. TYPE provides the characteristics of the field and the NAME specifies a name to the field by which it can be referred.

What are the collections of Application Object?
* Contents collection - contains all variables added via scripts in global.asa.
* Static collection - contains the names of all objects.

Questions To Ask The HR

What kinds of assignments might I expect the first six months on the job?

How often are performance reviews given?

Please describe the duties of the job for me.

What products (or services) are in the development stage now?

Do you have plans for expansion?

What are your growth projections for next year?

Have you cut your staff in the last three years?

Are salary adjustments geared to the cost of living or job performance?

Does your company encourage further education?

How do you feel about creativity and individuality?

Do you offer flextime?

What is the usual promotional time frame?

Does your company offer either single or dual career-track programs?

What do you like best about your job/company?

Once the probation period is completed, how much authority will I have over decisions?

Has there been much turnover in this job area?

Do you fill positions from the outside or promote from within first?

Is your company environmentally conscious? In what ways?

In what ways is a career with your company better than one with your competitors?

Is this a new position or am I replacing someone?

What is the largest single problem facing your staff (department) now?

May I talk with the last person who held this position?

What qualities are you looking for in the candidate who fills this position?

What skills are especially important for someone in this position?

What characteristics do the achievers in this company seem to share?

Who was the last person that filled this position, what made them successful at it, where are they today, and how may I contact them?

Is there a lot of team/project work?

Will I have the opportunity to work on special projects?

Where does this position fit into the organizational structure?

How much travel, if any, is involved in this position?

What is the next course of action? When should I expect to hear from you or should I contact you?

What to Ask After the Offer

All job hunters are waiting for that call -- the one that says they've landed the job. But as eager as you may be to escape either your current job or the unemployment ranks, don't abdicate your power position once the offer comes in. Now it's your turn to sit in the interviewer's seat and ask the company and yourself some tough questions -- the answers to which could mean the difference between career bliss and disaster.

Will the actual work and job responsibilities provide gratification, fulfillment and challenge?

This question is often overlooked, because applicants get hung up on job titles, salary and benefits. Try to get a clear sense of what an actual day would be like. What will you spend the majority of your time doing? Is the work in line with your values? Will you likely learn this job quickly and become bored and unchallenged?

What are the boss's strengths and weaknesses?

This question can be tough to answer, and it's best saved for after the job offer has been extended. You'll want to get a good idea for your potential boss's management style. Speak to your potential boss as much as possible to get a feel for his personality and what you can live with. Does he micromanage? Will you get consistent feedback and reviews? Does he make small talk, or is every conversation strictly business?

How much change is in the works at your prospective company, and what kind?

Constant change at work can mean constant stress. Find out if there are any big changes coming, such as new processing systems or management, impending retirements or adoption of new procedures that still need to be ironed out. At the same time, remember that some of these transitions will have less effect on your position than others.

How many of my skills and experiences will I be able to use and learn?

Make sure your unique skills and talents will be used and that training and promotion are open in the future. When you decide to move on, you'll want to have a new crop of experiences to sell to your next employer. Your goal is to perform well at work while constantly growing and learning.

How many people have held the position in the past several years?

Knowing how many people have been in your job and why they left can offer you great insights. You'll want to know if they were promoted or quit altogether. A steady stream of resignations may be a sign you could be reentering the job market soon.

While many of the reasons positions eventually become unfulfilling are unavoidable, such as hitting a plateau after repeatedly performing the same duties, job seekers should consider the ways a new position will advance them