Monday, April 26, 2010

JSP FAQ


. What is JSP ? Describe its concept.

2 . Explain the benefits of JSP?

3. Is JSP technology extensible?

4 .Can we implement an interface in a JSP?

5 What are the advantages of JSP over Servlet?

6. Differences between Servlets and JSP?

7 . Explain the differences between ASP and JSP?

8 . Can I stop JSP execution while in the midst of processing a request?

9. How to Protect JSPs from direct access ?

10. Explain JSP API ?

11. What are the lifecycle phases of a JSP?

12. Explain the life-cycle mehtods in JSP?

13. Difference between _jspService() and other life cycle methods.

14 What is the jspInit() method?

15. What is the _jspService() method?

16. What is the jspDestroy() method?

17. What JSP lifecycle methods can I override?

18. How can I override the jspInit() and jspDestroy() methods within a JSP page?

19 . Explain about translation and execution of Java Server pages?

20 . Why is _jspService() method starting with an '_' while other life cycle methods do not?

21. How to pre-compile JSP?

22. The benefits of pre-compiling a JSP page?

23.How many JSP scripting elements and explain them?

24. What is a Scriptlet?

25. What is a JSP declarative?

26. How can I declare methods within my JSP page?

27. What is the difference b/w variable declared inside a declaration and variable declared in scriplet ?

28.What are the three kinds of comments in JSP and what's the difference between them?

29. What is output comment?

30. What is a Hidden Comment?

31. How is scripting disabled?

32. What are the JSP implicit objects?

33. How does JSP handle run-time exceptions?

34. How can I implement a thread-safe JSP page? What are the advantages and Disadvantages of using it?

35. What is the difference between ServletContext and PageContext?

36 . Is there a way to reference the "this" variable within a JSP page?

37 . Can you make use of a ServletOutputStream object from within a JSP page?

38 .What is the page directive is used to prevent a JSP page from automatically creating a session?

39. What's a better approach for enabling thread-safe servlets and JSPs? SingleThreadModel Interface or Synchronization?

40. What are various attributes Of Page Directive ?

41 . Explain about autoflush?

42. How do you restrict page errors display in the JSP page?

43. What are the different scopes available fos JSPs ?

44. when do use application scope?

45. What are the different scope valiues for the ?

46. How do I use a scriptlet to initialize a newly instantiated bean?

47 . Can a JSP page instantiate a serialized bean?

48.How do we include static files within a jsp page ?

49.In JSPs how many ways are possible to perform inclusion?

50.In which situation we can use static include and dynamic include in JSPs ?

51.Differences between static include directive and include action ?

Monday, March 8, 2010

Vb Script to call a web service

Dim oXMLDoc, oXMLHTTP

Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")
Set oXMLDoc = CreateObject("MSXML2.DOMDocument")
Msgbox("Calling WebService ")
oXMLHTTP.onreadystatechange = getRef("HandleStateChange")
call oXMLHTTP.open ("POST","http://localhost:1673/WebService1.asmx/Helloworld",false)
call oXMLHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
'send input parameters
oXMLHTTP.send "a=1"


Sub HandleStateChange
if(oXMLHTTP.readyState = 4) then
dim szResponse
szResponse = oXMLHTTP.responseText
call oXMLDoc.loadXML(szResponse)
if(oXMLDoc.parseError.errorCode <> 0) then
call msgbox(oXMLDoc.parseError.reason)
else
msgbox(oXMLDoc.getElementsByTagName("string")(0).childNodes(0).text)
end if
end if
End Sub

Thursday, February 18, 2010

Remoting FAQ

What is Application domain?
In application domains Multiple appication can run in same process with out influencing each other.If one of the application domain throws error it doesnot affect aother applicaation domain.TO invoke method in a objec wunning in differnt application domain .Net remoting is used.
What is .NET Remoting
.Net remoting is the replacement of DCOM.Using .Net remoting we can make remote object calls to the methodsthat are running in differnt application domains.As the remote objects run in differnt process client callingthe remote object canot call it directly.so the client uses a proxy which looks like a real object.

when a client want to make a method call on the remote object it uses proxy of it.These method call are called "Messae".Messages are serialized using "formatter" class and sent to the client "chanel".Client channel communicate with the server channel.Server channel uses a formatter class to deserialize themessage and send to remote object.

which class does remote object to inherit?
All remote objects must inherit System.MarshallByRefObject Class

what are two differnt types of remote objects creation mode in .net?
The two different types of remote objects creation are
Server Activated Object mode
Client activated Object mode
Server Activated object is also called as "Call mode".In this type of creation we have two differnt modes ofcreating object."Single Call" and "Singleton".
In single Call mode object is created for every method call hence it is stateless.In Singleton mode object is created only once and it is shared to all clients.
Client activated objects are statefull.In CAO the creation request is sent from clientside. Client holds a proxy to the server object created on server.

Describe in detail Basic of SAO architecture of Remoting?
Left to user.

What is fundamental of published or precreated objects in Remoting?
In scenarios of singleton or single call the objects are created dynamically. But in situationswhere you want to precreate object and publish it you will use published object scenarios.
Dim obj as new objRemoteobj.Initvalue = 100
RemotingServices.Marshal(obj,”RemoteObject”)
RemotingServices.Marshal(obj,”RemoteObject”)
where “obj” is the precreated objectedon the server whose value is initialized to 100

What are the ways in which client can create object on server in CAOmodel ?
Activator.CreateInstance(). By Keyword “New”.

In CAO model when we want client objects to be created by “NEW”keyword is there any precautions to be taken ?
Remoting Clients and Remoting Server can communicate because they share a commoncontract by implementing Shared Interface or Base Class.
But according to OOP’s concept we can not create a object of interface or Base Classes
Shipping the server object to client is not a good design practice. InCAO model we can use SOAPSUDS utility to generate Metadata DLL from server whichcan be shipped to client, clients can then use this DLL for creating object on serverRunthe SOAPSUDS utility from visual studio command prompt for syntax see below :-
soapsuds -ia:RemotingServer -nowp -oa:ClientMetaData.dll
Where RemotingServer is your server class name.ClientMetaData.dll is the DLL name by which you will want to create the metadll.

What are LeaseTime, SponsorshipTime, RenewonCallTime and LeaseManagerPollTime

In normal .NET environment objects lifetime is managed by garbage collector. But in remoting environment remote clients can access objects which are out of control ofgarbage collector. Garbage collector boundary is limited to a single PC on which frameworkis running; any remote client across physical PC is out of control of GC (GarbageCollector).

This constraint of garbage collector leads to a new way of handling lifetime for remotingobjects, by using concept called as “LeaseTime”. Every server side object is assigned bydefault a “LeaseTime” of five minutes. This leasetime is decreased at certain intervals.Again for every method call a default of two minutes is assigned. When i say method callmeans every call made from client. This is called as “RenewalOnCallTime”.Let’s put the whole thing in equation to make the concept more clear.
Total Remoting object life time = LeaseTime + (Number of method calls) X(RenewalTime).

If we take NumberOfMethodCalls as one.159
Then default Remote Object Life Time = 5 + (1) X 2 = 10 minutes (Everything is inminutes)
When total object lifetime is reduced to zero, it queries the sponsor that should the objectbe destroyed. Sponsor is an object which decides should object Lifetime be renewed. Soit queries any registered sponsors with the object, if does not find any then the object ismarked for garbage collection. After this garbage collection has whole control on theobject lifetime. If we do not foresee how long a object will be needed specify the“SponsorShipTimeOut” value. SponsorShipTimeOut is time unit a call to a sponsor istimed out.
“LeaseManagerPollTime” defines the time the sponsor has to return a lease time extension.

Which config file has all the supported channels/protocol ?
Machine.config file has all the supported channels and formatter supported by .NETremoting.Machine.config

What is a Web Service ?
Web Services are business logic components which provide functionality via the Internetusing standard protocols such as HTTP.Web Services uses Simple Object Access Protocol (SOAP) in order to expose the businessfunctionality.SOAP defines a standardized format in XML which can be exchangedbetween two entities over standard protocols such as HTTP. SOAP is platform independentso the consumer of a Web Service is therefore completely shielded from anyimplementation details about the platform exposing the Web Service. For the consumer itis simply a black box of send and receive XML over HTTP. So any web service hosted onwindows can also be consumed by UNIX and LINUX platform.


What the different phase/steps of acquiring a proxy object inWebservice
Client communicates to UDI node for WebService either through browser orUDDI's public web service.
UDII responds with a list of webserviceEvery service listed by webservice has a URI pointing to DISCO or WSDLdocument
After parsing the DISCO document, we follow the URI for the WSDL documentrelated to the webservice which we need.
Client then parses the WSDL document and builds a proxy object which cancommunicate with Webservice.


What is WSDL?
Web Service Description Language (WSDL)is a W3C specification which defines XMLgrammar for describing Web Services.XML grammar describes details such as:-
Where we can find the Web Service (its URI)?
What are the methods and properties that service supports?
Data type support. Supported protocols


What is DISCO ?
DISCO is the abbreviated form of Discovery. It is basically used to club or group commonservices together on a server and provides links to the schema documents of the servicesit describes may require.

What is UDDI ?
Full form of UDDI is Universal Description, Discovery and Integration. It is a directorythat can be used to publish and discover public Web Services
What is ObjRef object in remoting ?
All Marshal() methods return ObjRef object.The ObjRef is serializable because itimplements the interface ISerializable, and can be marshaled by value. The ObjRef knowsabout :-
√ location of the remote object
√ host name
√ port number
√ object name.

Wednesday, February 10, 2010

Normalization

Normalization:

A series of steps followed to obtain a database design that allows for efficient access and storage of data in a relational database

Normalization helps
to optimize the database by thorugh investigation of relation ships.
It is used mainly to avoid redundacy of data and for scalability issues,

The Process towards database Normalization Progresing through series of Steps typically Known as Normal forms.




First Normal Form

‘A relation R is in first normal form (1NF) if and only if all underlying domains contain atomic values only.’

the first rule call for elimination of repeating groups of data through the creation of seperate tables of related data


Second Normal Form

‘A relation R is in second normal form (2NF) if and only if it is in 1NF and every nonkey attribute is fully dependent on the primary key.’



Third Normal Form

‘A relation R is in third normal form (3NF) if and only if it is in 2NF and every nonkey attribute is nontransitively dependent on the primary key.’

Boyce/Codd Normal Form

‘A relation R is in Boyce/Codd normal form (BCNF) if and only if every determinant is a candidate key.’

Type Casting in C#.net

TypeCasting:
Typecasting is the name given to transforming one type into another. There are two types of casting that can be performed on data types,
implicit and explicit

Implicit Typecast
Implicit casting is performed by the compiler when there is no possible loss of data. This is when a smaller data type is copied into a larger data type - e.g., converting a 16-bit short to a 32-bit integer value

Expilicit TypeCast:
Explicit casting requires the use of the cast operator (parentheses) when there is a possible loss of data
int fourBytes = 0x000000FE;
byte lowestByte = (byte)fourBytes;

int numericval=67;
byte bytevalue= (byte) numericvalue;

String to Byte Array Conversion in C# and VB.NET :

Convert string to byte Array in C#.net
public static byte[] StrToByteArray(string str){
System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}

Converting Byte Array to String:
byte [] dBytes = ...
string str;
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
str = enc.GetString(dBytes);


Convert Integer to Byte :
Use BitConverter to convert integer values to byte
byte[] numBytesBuf = new byte[4];
numBytesBuf =System.BitConverter.GetBytes(int32Input);

Convert bitarray to Int

BitConverter.ToInt32 Method
Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array.

Infosys Scholarship

Infosys Scholarship for Poor Students who completed 10th std.-Pls. Read & Forward to benefit the needy Dear Friends, If you have come across any bright students coming from poor financial background who have finished their 10th standard this year (April 2009) and scored more than 80%, please ask them to contact the NGO-Prerana (supported by Infosys foundation). The NGO is conducting a written test and those who clear the test will be eligible for financial help for their further studies.


Please ask the students to contact the people mentioned below to get the form #580,


Shubhakar , 44th cross,1st A main road,jayanagar 7th block Bangalore
Mob no- 9900906338(saraswat i)
Mr. Shivkumar ( 9986630301) - Hanumanthnagar office
Ms. Bindu (9964534667 )-Yeshwantpur office


Even if you dont know anyone, please pass on this info, someone might be in need of this help desperately

Sunday, February 7, 2010