Wednesday, 15 October 2014

What is JAX-P-

Hello and welcome to JAX-P article,

in this article,we will discuss details about JAX-P. JAX-P stands for XML processing.

As we disscussed in 'What is XML' article, XML is also a document which contains data.

earlier there were no options in JAVA to read XML files, users has to use java I/O to XML document.

later JAVA has provided to this API to process XML documents.

XML can be read either from starting or in random order ,JAVA provides two types of parsers to process XML files.

SAX-PARSER :

SAX parser reads the document in sequential order.
it is event based parser.
there are different types of events called document start,element start,element end..

it can read only one element at any time.
it uses less memory
it is fast compared with DOM parser.

SAXParserFactory saxparserFactory=
SAXParserFactory.newInstance();

 SAXPARSER parser=saxparserFactory.newSAXParser();

using parser, we can parse the XML documents. it provides some set of methods to perform the read operations

SAX parser can only read the documents.

Web services-Part 01

Web services is a technology, using which applications of two different technologies can communicate with each other.

the application which implements web services is called provider

and the application which uses these web services is callled consumer.

W3C organization has provided some set of guidelines to implement web services.

Initially W3C has released a document with set of guidelines that document is called BP 1.0 (Basic profile).

Java has provided JAVA-RPC specification to follow these guidelines and to implement web services

later W3C has provided a document another set of guidelines called BP1.1. java has provided JAVA-WS API to implement these guidelines

Once we implement web services using any of the above API, we need to provide their details using WSDL.

WSDL stands for web services description language, using which we can provide details about our services and methods and heir parameters

When a consumer wants to use these web services, they can refer this WSDL document.


once this WSDL is ready, and if you want to make your web services public, we can add this WSDL in UDDI

UDDI stands for universal desciption,directory integration.
we can add details about our web services in UDDI.

read our next article to understand more about web services


What is XSD


Hello and welcome to this article... in this article, we will see some basic details of XSD

XSD stands for XML Schema definition.

in XSD root tag is mandatory, all other tags should come under this XSD.

as we already know,XML can contain either simple tag or compound tag.

to define simple tag, we can use

<xs: element name="itemcode" type="xs:string">

to define complex attributes, XSD provides xs:complexType as shown below.


<xs:complexType name="address">
<xs:sequence> or <xs:all>
 <xs: element name="street" type="xs:string">
<xs:element name="state" type="xs:string">
</xs:sequence> or </xs:all>
</xs:complexType>

when we use xs:sequence, it specifies the all the nested elements should come in the same order
 
when we use xs:all, these attributes can come in any order

once we define a complex element, we can refere them in any other complex types

<xs:element name="permentaddr" type="address">

</xs:element>


Working with multipole XSDs
________________________________

If you want to refer one XSD in another XSD, we can use import or include.

if both XSDs are in same location, we  can use include

if both XSDs are in different locations, we use import

<xs:schema targetNamespace="xxxx">
</xs:schema>

<xs:schema targetnamespace="XXX">

<xs:include schemalocation="po1.xsd"

</xs:schema?



Sunday, 28 September 2014

What are different JSP scriptlets ?

JSP provides different scriptlets to use java code in JSP.

1.Directives Tag

<%@ %>
-------------

This tag is used to include external content in our jsp

this tag has mainly three attributes

1.Page
2.taglib
3.include

<%@ taglib uri="relative UR""  prefix=""%>

when we have predefined,custom tags, we can include them in our JSP and use them with prefix.

<%@ page import="relaive url" %>

this works similar to import statement in Java.

<%@ include file="relative url"%>

include attribute can be used  to include external js,jsp and css files

file will  be included in our file during the translation phase.

II. Declarative tag
-----------------------
<%! %>
This tag is used to declare variables in JSP

<%! int a;%>

III. Expression tag
--------------------------

This tag is used to write any expressions which result in string.

<%=Expression%>

we should not use semicolon at the end of the expression


IV. JSP comments
-----------------------

<% -- comments---%>

used to write comments in JSP

What do you know about JSP life Cycle?

Hey Guys.... here I will try to explain basic details of JSP which might be useful for the people who are beginners.

JSP :JSP stands for JAva Server Pages.

Most of you know might know about HTML which is used to display static content.Using JSP we can write pages which displays dynamic content to the user based on server response.

Main advantage of JSP is it is built on Servlet API so it has acess to all Java API like JDBC,JNDI,JAXP.

Let me explain lifeCycle of JSP:

JSP life cycle has below three steps:

1.Initilisation
2.Execution
3.CleanUp

Initilisation :

jspInit() method is executed during phase. this method will execute when JSP is loaded into memory.

once JSP is loaded, JSP container converts it to servlet and compiles it.

Then JSP container passes request to servlet container. Servlet container then executes the servlet which sends the response to client

Execution Phase 

:During this phase, jsp will process all requests from users and sends the response.

_jspService(HttpServletRequesst,HttpServletResponse) method is used to process all user requests.

This method will be executed once for each request.

CleanUP :

during this phase,the resources which are allocated during initilisation phase are cleaned.
jspDestroy( ) method will be executed during this phase.
 

Search This Blog