Archive for the ‘Tips & Tricks’ Category

Interface Programming tool A Concept

Interface is technique or concept which is used to add set of behavior or functionality to be mandatory. When we derive into class then class has to implement each thing that is in Interface. Something like making skeleton and then giving different look and behavior using that skeleton. Decoupling of object and  its implementation is possible because of interface.

Lets say you create interface of Cycle

Interface ICycle
void Handle(); 
void Wheels(); 

Inheriting class

class AtlasCycle: ICycle
void ResizableHandle()
void fourDiaWheels()


Above cycle skeleton can be used to derive any brand of bicycle with different feature values.

  • Interface has by default all fields, properties and methods Public. But you can have internally private and use it appropriately inside interface.
  • One which is public has to be implemented in inheriting class So it better than having base class.
  • Class can inherit as many as interfaces So structures can also use interfaces.
  • Interface does not have implementation only declarations.
  • It is highly used to design architecture. So it is architecture job to define what to be exposed and what not to client.

Happy Programming..

Number of View :8948

No Comments

C# Language Features OOPS .NET

Quick walkthrough on C# features.


Object Types: It is parent type of all other known types in .Net. If used as an argument in Method call then passing any type to method will cause late binding assignment to that argument.
Value and Reference Type: This type categorized on the storage of value in memory. Value Type are stored in Stack. e.g type INT, DOUBLE.
Reference types are stored in heap. e.g Type String and Object.
Converting value type into reference type called as Boxing and reverse is UnBoxing.

C# allows simple and component variable declaration.

It is declared as set which are mapped to integers. This type allows us to have series which can have their mapping to unique integer value inside the set.

public enum EmployeeRole{ Trainee=0, Programmer=1, Sr Programmer=2}


Arrays: This type holds list.

int [] intArray;


OPERATORS Representing symbols for operations.
e.g Arithmetic[+, _, +], Logical[||, &&], String Concatenate[&], Increment and Decrement[+=], Comparison[<=, =>], Cast[()] etc..

FLOW CONTROL Controls the flow of your programme. e.g conditional statement [if ..else, switch], loops[while, do..while, for, foreach], functions.

CLASSES Class is type which includes all types, members, methods etc. It has visibility, its lifetime, relation, inheritance, method overloading..

REFLECTION Dynamically gather information of underlined type in late bound fashion. e.g Attributes allows to attach metadata to class and its members.

INTEROPERABILITY This feature facilitates to work with other programming language and API.
COM INTEROPERABILITY: This allows to integrate legacy components with .Net classes.
INVOKING WINDOWS API: This is same as VB6 feature to invoke and use windows API. Reference dll and create wrapper functions.

private static extern int MessageBoxA(int hwind, string Message, string caption, int Type);


STRUCTURED ERROR HANDLING This is way of handling error by blocking code. e.g



C# PREPROCESSOR This feature allows programmer to do better programming like expanding code, collapsing code…

Happy programming..

Number of View :7950


No Comments

Microsoft office 2007 OneNote How to use OneNote?

First Lets understand OneNote. What is OneNote? It is one of information capturing service or feature of Microsoft Office 2007. Capturing notes, saving notes, browsing your notes and also sharing notes is all possible with our regular paper notebook.. Here is the difference, Its all that what we have been doing for taking notes in office or any other place and writing information into our NoteBook and In one OneNote it is mobile, we can carry anywhere and share anywhere. What is special in OneNote, well you can carry your text capturing device anywhere so you have onenote that device whether its smartphone or digital notebook, windows phone , Second its office features, graphics and speed So you can carry it anywhere and share it. Unlike Paper you can copy info from other files, you can copy , create images and save it in page.

For onenote you can work offline or work online.

Onenote has text, Image, video , audio capturing features.
You can create your own template and customize it.
Can share notes with others.
You can use notebook multiple computers.

How to Use OneNote?
You need to install Office 2007 for better features.Latest you have Office 2013 Onenote.
Then you can start working with OneNote right away. Detail information can be found at office site of microsoft

Number of View :3447

No Comments

.Net Application With Windows Azure 1.8

Now I have Installed Windows SDK 1.8 kit and started developing application using video shown in MSDN. But the catch is it is old and the configuration or publishing site ways are improved.

To develop ASP.NET application on VS2010 follow steps as below
1) Open VS 2010 -> File Menu -> New -> Project
2) Under Project window you can see various language and options, I am selecting c# and then Cloud here you see at right Panel is Windows Azure Cloud Service

VS 2010- Project- Cloud

VS 2010- Project- Cloud

3) Give name and location of project to save.
4) Next step it will open window to select the project type

Select Cloud Project Type

Select Cloud Project Type

But why is project type with Role like Web, Worker and VM? In short they are nothing but your Web Configuration role. Like you want use IIS for application, you want to run it locally with worker process or using VM… you can find good explanation in msdn,
Have patience here it takes time to get your code files service files to be generated.
Project With all file
4) Now you can do implementation in your project which is of WebRole type.
5) Ones you are ready for hosting of course we will do it on windows azure, select WebRole Project Properties -> Publish to Windows Azure
6) Now here your Windows Azure journey starts , Create Login in if you have already use it. When you try for Trial you still need to provide your bank account details. When you come to Publish First windows will be asking Import credentials which you have, If you have not saved your Credentials from Windows azure login save it by choosing Sign in to download credentials.
Sign in Windows azure

Click Next.
7) Here you need to fill correct details. Read about Windows azure before you do settings in publish.
Options for Create Cloud Publish

As per above image you need to specify Cloud Service(Select Create New from drop-down and give name and location) Name which we give here will become your URL. Provide all other details as well.
8) Go to Advanced Setting Tab and create New Storage Account.
9)Click on Publish.. and Wait for Status in task bar of your project as completed.
This time here it will perform connection with Windows Azure and create your application.
10) Ones you have no failure and Status shows as Completed you can click the URL given in output results and browse.

few steps are different than the videos given by msdn.

Happy Programming..

Number of View :6748

Tags: , , ,

No Comments

Basic Standard Action Tags In JSP Tutorial With Examples JSP Technical Advices

Standard Action Tags In JSP

Standard Action Tags In JSP are meant for performing some action at run time. As the name of the tag itself suggests these tags are used for run time behavior. Unlike scripting tags which are meant for generating related servlet code at the time of translation,Standard Action Tags In JSP generates code for run time behavior.


Examples of Standard Action Tags In JSP are as follows :


  1. <jsp:include file= ”AnotherJsp.jsp”/>
  2. <jsp:forward file=”AnotherJsp.jsp”/>
  3. <jsp:useBean id=”obj” type=”SomeBean” class=”SomeBean” scope=”request”>
  4. <c:set var=”attrName” value=”attrVal” scope=”request”/>


There are so many other tags as well amongst which these are some and important.

Let us take these tags individually as see how do they contribute for Standard Action Tags In JSP


  1. <jsp:include file= ”AnotherJsp.jsp”/> : This tag is used for run time inclusion of another JSP page in an existing one. This inclusion is not similar to inclusion with include directive. Include directives are meant for static inclusion. This means that the code from the included JSP will be included int the including JSP at the translation time. But in the case of <jsp:include file= ”AnotherJsp.jsp”/> tag a run time call to the included JSP is done and the response from the included JSP is added to the response of the including JSP.
  2. <jsp:forward file=”AnotherJsp.jsp”/> : This tag is used for forwarding the request to another JSP at run time. The difference here from run time or dynamic inclusion is that here the response from the forwarded JSP only goes to the user and the response from the first JSP from where the forward happens gets flushed out.
  3. <jsp:useBean id=”obj” type=”SomeBean” class=”SomeBean” scope=”request”> : This tag is used to create or fetch a java bean object ,set or get its property value/s and retrieve or set this java bean object in certain scope.
  4. <c:set var=”attrName” value=”attrVal” scope=”request”/> : This tag is used to set an attribute in a particular scope.This is an important tag as our MVC applications rely heavily on attributes
Number of View :5847

Tags: , , , , ,

No Comments

Explain Different Types Of Tags In JSP Interview Asked Questions And Answers

Different Types Of Tags In JSP


Java Sever Page (JSP) is an abstraction for servlet in which we have less java code and more tags(HTML and JSP). A JSP page is basically used for views with dynamic data(unlike HTML) and evolved basically for people who do not know java and still work at j2ee server side programming.

Depending upon the type of the usage the tags in JSP page are categorized as :


  1. Scripting Tags
  2. Standard Action Tags
  3. Custom Tags

Scripting Tags : These tags are meant for compile time and translation.This means that these tags are meant for translation of code to the servlet. Different types of scripting tags are:

a. Directive Tag

b. Declarative Tag

c. Scriptlet Tag

d. Expression Tag


a. Directive Tag : There are three types of directive tags :

1.Page Directive : It is used for imports,encoding etc.

Example: <%@ page import=”…” %>

2.Include Directive : Its is used for static inclusion of JSP and HTML pages

Example: <%@ include file=”anotherJsp.jsp” %>

3.Tag lib Directive: It is used for including tag libraries

Example: <%@ taglib uri=”…” prefix = “..”%>

b. Declarative Tag : These tags are used to declare variables or methods for the servlet translated servlet class.

Example: <%! int i =0;%>


c. Scriptlet Tag : These tags are used to write java code inside the JSP page.What goes inside the scriptlet tag is merged into the service method of the translated servlet code.

Example: <% System.out.println(“Hello”);%>


d. Expression Tag : These tags are used to print expressions.What is written inside this tag goes as an argument for out.print() inside the service method of the translated servlet.

Example : <%= “Hello” %>


It should be noted that we do not use semicolon inside expression tag because it will go as an argument in ou.print() function,hence will result in syntax error.While in case of declarative tag and scirptlet tag we use semicolon.

Number of View :6467

Tags: , , , , , , , , , , ,

No Comments

How To Get Servlet Init Parameters In JSP

How To Get Servlet Init Parameters In JSP

We know that we can declare init parameters for JSP file in web.xml file as we do in the case of servlet.The entry in the web.xml file will be as follows:


Now comes the question that how can be access or retrieve those initialization parameters in the JSP page.Among the life cycle methods of a JSP page jspInit() method is one of the methods which can be overridden.The jspInit() method is called by the init() method of the servlet which is the result of the translation of the JSP page.To access the initialization parameters is one of the cases where we override the jspInit() method.When we need to declare a method we use the declarative tag as follows :

 public void jspInit()
   ServletConfig sConfig = getServletCOnfig();
   String str= sConfig.getInitParameter(“paramName”);

Here we have overridden the jspInit() method in the declarative tag.Since this method is called by the init method of the translated servlet code we can access the servlet config object with the help of getServletConfig() method as it is passed by the server to the servlet through init() method. This method (jspInit()) will appear as an overridden method in the translated servlet.The point should be noted here that init() method in the servlet calls this jpInit() life cycle method of the  jsp page so it can access the servlet config object.The life cycle method _jspService() is not permitted to be overridden .Initialization parameters for the the JSP page can be understood as the configuration parameters to be accessed by the translated servlet.After all a JSP page is a servlet at the end of the day and it is the translated servlet only which processes the requests from the clients.




Number of View :8617

Tags: , , , , , , , , , , ,


Declare Servlet Init Parameters For JSP Page In web.xml File JSP Initialization FAQ

How To Declare Initialization Parameters For JSP Page In web.xml file

Servlet initialization parameters are declared  inside web.xml page and are used to pass the value to the servlet as a part of configuration.Now the question comes that since we do not make an entry for JSP inside web.xml page,how to pass the init parameters to the JSP page.We should remember that a JSP page is a servlet at the end of the day.A JSP is ultimately converted into a servlet then only it processes requests.Like the entry for init parameters in web.xml in case of servlet we make an entry for the JSP page as well,but with a slight difference.The web.xml file looks like this :


Here we can find that the same way as we declare  init paramters for servlet within the servlet tags,the same way we make an entry for the JSP page so that the init parameters can be declared for that particular JSP page.The only difference is that instead of he <servlet-class> tag we use <jsp-file> tag.The url pattern for the JSP page is same as the JSP file name as we use the JSP file name as URL pattern in the request.Inside the <jsp-file> tag we use the JSP file name with .jsp extension because we need to access the JSP page and not the servlet class.

This is the way we declare servlet init parameters for the JSP page inside the web.xml file.We call it as servlet init parameters for JSP page because these init parameters are sent to the servlet which is the result of translation of the JSP page.And these are used as the configuration parameters for the translated servlet.Now the init parameters can be accessed in he JSP page code.

Number of View :7541

Tags: , , , , , , ,

1 Comment

Define URL Rewriting Frequently Asked Interview Question Answers

What Is URL Rewriting


As we know that session needs to be maintained because http is a stateless protocol.Due to which connection is lost or session is lost after every request response cycle between the client and the server.In order to maintain or track the session the server needs to get the additional information of the session id so that the session object pertaining to the client or server can be retrieved at the server side and the session can be managed.The session can be managed by either  cookies,hidden parameter or URL rewriting.

URL Rewriting is used in the cases where client browser does not accept cookies.In such case the server does not get the session id thus it is unable to relate he session object with the client or user.In order to maintain the session some extra piece of code needs to be added so that even if the cookies are not accepted at the browser level still the session can be maintained.URL Rewriting is something to fall upon as a precautionary measure.The code to get session and URL Rewriting is demonstrated below :

out.println("<a href = "\"+response.encodeURL()+""\>Click Here</a>");

Here the anchor tag is used for URL Rewriting.Since the extra measure is used to take care that if the client browser does not accept cookies the session id is attached to the URL so that the session can be maintained.In URL Rewriting the session id is passed as an extra information with the URL that means rewriting of the URL is done.URL Rewriting can also be done with redirection as below :

response.sendRedirect(response.encodeRedirectURL("URL-Pattern of the servlet"));

The first time the server  tries with both cookies and URL Rewriting ,if it finds that the cookies are not coming it checks for session id as a part of URL Rewriting and finds that it has to fall upon URL Rewriting if the code has provisioned that.


Number of View :5908

Tags: , , , , , , , , ,

No Comments

Basic Servlet Attributes Thread Safety Interview Questions Answers Explained

Servlet Attributes Thread Safety  

An attribute is used to communicate some value from one servlet to another. Depending upon the scope of the attribute we can access the attributes at parts of the application.An attribute can be set at either of the scopes as follows :





Now in order to find out which attribute/s is/are thread safe,we can ponder upon with following discussion.

1.Application Attributes : An application attribute is a value set at application level. The code to set the attribute at application level is :


As these attributes are accessible throughout the application,any servlet or any other web entity can update or get these attributes from various parts of the application. Since application attributes can be accessed or modified by any servlet in the web application,these are not thread safe.


2.Session Attributes : A session attribute is a value set at session scope. Session is used to retain user specific data. The code to set the attribute at application level is :


When we talk about thread safety of session attributes,at one glimpse it deceives to appear as thread safe. In cases where we have the new tab feature in the modern browsers,the same session for the web application is opened in the new tab. In such case, if session attribute are updated from one tab will be reflected in the another tab with the same session. Thus we can say that session attributes are also not thread safe.

3.Request Attributes : A request attribute is a value set at request scope.he code to set the attribute at application scope is :


As we know that each request is a unique object , whatever attribute we set at request scope cant be updated or get from another request. Thus request attributes are thread safe.

Conclusion : Thus request attributes are thread safe and application and session attributes are not.

Number of View :8160

Tags: , , , , , , , , ,

No Comments

Content Protected Using Blog Protector By: PcDrome.