tag:blogger.com,1999:blog-64514243669260729382024-03-14T02:51:44.057+05:30Java-RulesLearn Java By Rules And From The ErrorsJava Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comBlogger83125tag:blogger.com,1999:blog-6451424366926072938.post-75541867626103977672019-05-15T19:00:00.001+05:302019-05-15T19:00:44.718+05:30Java8 Add Numbers<div dir="ltr" style="text-align: left;" trbidi="on">
@FunctionalInterface<br />
interface AddNumbers{<br />
<span style="white-space: pre;"> </span>public int addNumbers(int x, int y);<br />
}<br />
<br />
public class Java8AddNumbers {<br />
<br />
<span style="white-space: pre;"> </span>public static void main(String[] args) {<br />
<span style="white-space: pre;"> </span>AddNumbers addNumbers = (x, y) -> x+y;<br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>int result = addNumbers.addNumbers(10, 30);<br />
<span style="white-space: pre;"> </span>System.out.println(result);<br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>}<br />
<br />
}<br />
<br />
<br />
<div>
<br /></div>
</div>
Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-77660225403829881552019-05-15T18:52:00.001+05:302019-05-15T18:53:51.754+05:30Java8 Print Hello<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
public class Java8PrintHello {<br />
<br />
<span style="white-space: pre;"> </span>public static void main(String[] args) {<br />
<span style="white-space: pre;"> </span>SayHello wish = name -> "Hello "+name;<br />
<span style="white-space: pre;"> </span>System.out.println(wish.sayHello("Sai Kumar"));<br />
<span style="white-space: pre;"> </span>}<br />
<br />
}<br />
<br />
@FunctionalInterface<br />
interface SayHello{<br />
<span style="white-space: pre;"> </span>public String sayHello(String name);<br />
}</div>
Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-24053505602107151362017-10-11T17:46:00.003+05:302017-10-11T17:46:28.885+05:30Hibernate Annotations Approach <div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<b>hibernate.cfg.xml</b><br />
<b><br /></b>
<b><br /></b>
<?xml version="1.0" encoding="UTF-8"?><br />
<!DOCTYPE hibernate-configuration PUBLIC<br />
<span style="white-space: pre;"> </span>"-//Hibernate/Hibernate Configuration DTD 3.0//EN"<br />
<span style="white-space: pre;"> </span>"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><br />
<span style="white-space: pre;"> </span><br />
<hibernate-configuration><br />
<session-factory><br />
<!-- Database connection properties - Driver, URL, user, password --><br />
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property><br />
<property name="hibernate.connection.url">jdbc:oracle:thin:@172.20.1.47:1521:XE</property><br />
<property name="hibernate.connection.username">DLAUDIT</property><br />
<property name="hibernate.connection.password">DLAUDIT</property><br />
<!-- Connection Pool Size --><br />
<property name="hibernate.connection.pool_size">10</property><br />
<br />
<!-- org.hibernate.HibernateException: No CurrentSessionContext configured! --><br />
<property name="hibernate.current_session_context_class">thread</property><br />
<br />
<!-- Outputs the SQL queries, should be disabled in Production --><br />
<property name="hibernate.show_sql">true</property><br />
<property name="format_sql">true</property><br />
<br />
<!-- Dialect is required to let Hibernate know the Database Type, MySQL, Oracle etc<br />
Hibernate 4 automatically figure out Dialect from Database Connection Metadata --><br />
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property><br />
<br />
<!-- mapping file, we can use Bean annotations too --><br />
<mapping class="com.hiberante.api.annotations.Account" /><br />
</session-factory><br />
<br />
</hibernate-configuration><br />
<br />
<br />
<b>Account.java</b><br />
<br />
<br />
package com.hiberante.api.annotations;<br />
<br />
import javax.persistence.Column;<br />
import javax.persistence.Entity;<br />
import javax.persistence.Id;<br />
import javax.persistence.Table;<br />
<br />
@Entity<br />
@Table(name="ACCOUNT")<br />
public class Account {<br />
<br />
<span style="white-space: pre;"> </span>@Id<br />
<span style="white-space: pre;"> </span>@Column(name="ID")<br />
<span style="white-space: pre;"> </span>private Integer id;<br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>@Column(name = "GUI")<br />
<span style="white-space: pre;"> </span>private String gui;<br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>@Column(name="FIRST_NAME")<br />
<span style="white-space: pre;"> </span>private String firstName;<br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>@Column(name="LAST_NAME")<br />
<span style="white-space: pre;"> </span>private String lastName;<br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>@Column(name="AGE")<br />
<span style="white-space: pre;"> </span>private Integer age;<br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>public Integer getId() {<br />
<span style="white-space: pre;"> </span>return id;<br />
<span style="white-space: pre;"> </span>}<br />
<span style="white-space: pre;"> </span>public void setId(Integer id) {<br />
<span style="white-space: pre;"> </span>this.id = id;<br />
<span style="white-space: pre;"> </span>}<br />
<span style="white-space: pre;"> </span>public String getGui() {<br />
<span style="white-space: pre;"> </span>return gui;<br />
<span style="white-space: pre;"> </span>}<br />
<span style="white-space: pre;"> </span>public void setGui(String gui) {<br />
<span style="white-space: pre;"> </span>this.gui = gui;<br />
<span style="white-space: pre;"> </span>}<br />
<span style="white-space: pre;"> </span>public String getFirstName() {<br />
<span style="white-space: pre;"> </span>return firstName;<br />
<span style="white-space: pre;"> </span>}<br />
<span style="white-space: pre;"> </span>public void setFirstName(String firstName) {<br />
<span style="white-space: pre;"> </span>this.firstName = firstName;<br />
<span style="white-space: pre;"> </span>}<br />
<span style="white-space: pre;"> </span>public String getLastName() {<br />
<span style="white-space: pre;"> </span>return lastName;<br />
<span style="white-space: pre;"> </span>}<br />
<span style="white-space: pre;"> </span>public void setLastName(String lastName) {<br />
<span style="white-space: pre;"> </span>this.lastName = lastName;<br />
<span style="white-space: pre;"> </span>}<br />
<span style="white-space: pre;"> </span>public Integer getAge() {<br />
<span style="white-space: pre;"> </span>return age;<br />
<span style="white-space: pre;"> </span>}<br />
<span style="white-space: pre;"> </span>public void setAge(Integer age) {<br />
<span style="white-space: pre;"> </span>this.age = age;<br />
<span style="white-space: pre;"> </span>}<br />
<span style="white-space: pre;"> </span><br />
}<br />
<div>
<br /></div>
</div>
Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-46179043343163986192017-10-11T17:44:00.000+05:302017-10-11T17:44:33.645+05:30Hibernate Declarative Approach <div dir="ltr" style="text-align: left;" trbidi="on">
<b>hibernate.cfg.xml</b><br />
<br />
<?xml version="1.0" encoding="UTF-8"?><br />
<!DOCTYPE hibernate-configuration PUBLIC<br />
<span style="white-space: pre;"> </span>"-//Hibernate/Hibernate Configuration DTD 3.0//EN"<br />
<span style="white-space: pre;"> </span>"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><br />
<span style="white-space: pre;"> </span><br />
<hibernate-configuration><br />
<session-factory><br />
<!-- Database connection properties - Driver, URL, user, password --><br />
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property><br />
<property name="hibernate.connection.url">jdbc:oracle:thin:@172.20.1.47:1521:XE</property><br />
<property name="hibernate.connection.username">DLAUDIT</property><br />
<property name="hibernate.connection.password">DLAUDIT</property><br />
<!-- Connection Pool Size --><br />
<property name="hibernate.connection.pool_size">10</property><br />
<br />
<!-- org.hibernate.HibernateException: No CurrentSessionContext configured! --><br />
<property name="hibernate.current_session_context_class">thread</property><br />
<br />
<!-- Outputs the SQL queries, should be disabled in Production --><br />
<property name="hibernate.show_sql">true</property><br />
<property name="format_sql">true</property><br />
<br />
<!-- Dialect is required to let Hibernate know the Database Type, MySQL, Oracle etc<br />
Hibernate 4 automatically figure out Dialect from Database Connection Metadata --><br />
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property><br />
<br />
<!-- mapping file, we can use Bean annotations too --><br />
<mapping resource="resorces/Account.hbm.xml" /><br />
</session-factory><br />
</hibernate-configuration><br />
<br />
<br />
<b>Account.hbm.xml</b><br />
<b><br /></b>
<!DOCTYPE hibernate-mapping PUBLIC<br />
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"<br />
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><br />
<br />
<hibernate-mapping><br />
<span style="white-space: pre;"> </span><class name="com.hiberante.api.declartive.Account" table = "ACCOUNT"><br />
<span style="white-space: pre;"> </span><id name="id" column="ID" type="java.lang.Integer"></id><br />
<span style="white-space: pre;"> </span><property name="gui" column="GUI" type="java.lang.String"/><br />
<span style="white-space: pre;"> </span><property name="firstName" column="FIRST_NAME" type="java.lang.String"/><br />
<span style="white-space: pre;"> </span><property name="lastName" column="LAST_NAME" type="java.lang.String"/><br />
<span style="white-space: pre;"> </span><property name="age" column="AGE" type="java.lang.Integer"/><br />
<span style="white-space: pre;"> </span></class><br />
<br />
</hibernate-mapping><br />
<b><br /></b>
<b><br /></b></div>
Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-87229785388640788382017-10-11T17:42:00.003+05:302017-10-11T17:42:46.491+05:30Hibernate Programmatic Approch<div dir="ltr" style="text-align: left;" trbidi="on">
package resorces;<br />
<br />
import java.util.Properties;<br />
<br />
import org.hibernate.SessionFactory;<br />
import org.hibernate.cfg.Configuration;<br />
<br />
import com.hiberante.api.programetic.Account;<br />
<br />
public class HiberanateConfig {<br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>//Property based configuration<br />
private static SessionFactory sessionJavaConfigFactory;<br />
<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span> private static SessionFactory buildSessionJavaConfigFactory() {<br />
<span style="white-space: pre;"> </span> try {<br />
<span style="white-space: pre;"> </span> Configuration configuration = new Configuration();<br />
<span style="white-space: pre;"> </span> <br />
<span style="white-space: pre;"> </span> //Create Properties, can be read from property files too<br />
<span style="white-space: pre;"> </span> Properties props = new Properties();<br />
<span style="white-space: pre;"> </span> props.put("hibernate.connection.driver_class", "oracle.jdbc.driver.OracleDriver");<br />
<span style="white-space: pre;"> </span> props.put("hibernate.connection.url", "jdbc:oracle:thin:@localhost:1521:XE");<br />
<span style="white-space: pre;"> </span> props.put("hibernate.connection.username", "DLAUDIT");<br />
<span style="white-space: pre;"> </span> props.put("hibernate.connection.password", "DLAUDIT");<br />
<span style="white-space: pre;"> </span> props.put("hibernate.current_session_context_class", "thread");<br />
<span style="white-space: pre;"> </span> props.put("hibernate.show_sql", true);<br />
<span style="white-space: pre;"> </span> props.put("format_sql", true);<br />
<span style="white-space: pre;"> </span> props.put("hibernate.dialect", "org.hibernate.dialect.OracleDialect");<br />
<span style="white-space: pre;"> </span> <br />
<span style="white-space: pre;"> </span> configuration.setProperties(props);<br />
<span style="white-space: pre;"> </span> <br />
<span style="white-space: pre;"> </span> //we can set mapping file or class with annotation<br />
<span style="white-space: pre;"> </span> //addClass(Employee1.class) will look for resource<br />
<span style="white-space: pre;"> </span> // com/journaldev/hibernate/model/Employee1.hbm.xml (not good)<br />
<span style="white-space: pre;"> </span> configuration.addAnnotatedClass(Account.class);<br />
<span style="white-space: pre;"> </span> <br />
<span style="white-space: pre;"> </span> //configuration.addClass(Account.class);<br />
<span style="white-space: pre;"> </span> //configuration.addResource("resorces/Account.hbm.xml");<br />
<span style="white-space: pre;"> </span> <br />
<span style="white-space: pre;"> </span> // ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();<br />
<span style="white-space: pre;"> </span> System.out.println("Hibernate Java Config serviceRegistry created");<br />
<span style="white-space: pre;"> </span> <br />
<span style="white-space: pre;"> </span> SessionFactory sessionFactory = configuration.buildSessionFactory();<br />
<span style="white-space: pre;"> </span> <br />
<span style="white-space: pre;"> </span> return sessionFactory;<br />
<span style="white-space: pre;"> </span> }<br />
<span style="white-space: pre;"> </span> catch (Throwable ex) {<br />
<span style="white-space: pre;"> </span> System.err.println("Initial SessionFactory creation failed." + ex);<br />
<span style="white-space: pre;"> </span> throw new ExceptionInInitializerError(ex);<br />
<span style="white-space: pre;"> </span> }<br />
<span style="white-space: pre;"> </span> }<br />
<span style="white-space: pre;"> </span> <br />
<span style="white-space: pre;"> </span> public static SessionFactory getSessionJavaConfigFactory() {<br />
<span style="white-space: pre;"> </span> if(sessionJavaConfigFactory == null) sessionJavaConfigFactory = buildSessionJavaConfigFactory();<br />
<span style="white-space: pre;"> </span> return sessionJavaConfigFactory;<br />
<span style="white-space: pre;"> </span> }<br />
<br />
}<br />
<div>
<br /></div>
</div>
Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-78597474162714838412017-10-11T17:41:00.000+05:302017-10-11T17:41:10.935+05:30Hibernate and Spring With Domain Scan Package<div dir="ltr" style="text-align: left;" trbidi="on">
<?xml version="1.0" encoding="UTF-8"?><br />
<beans xmlns="http://www.springframework.org/schema/beans"<br />
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br />
xmlns:context="http://www.springframework.org/schema/context"<br />
xmlns:tx="http://www.springframework.org/schema/tx"<br />
xmlns:mvc="http://www.springframework.org/schema/mvc"<br />
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd<br />
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd<br />
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd<br />
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"><br />
<br />
<!-- It register the beans in context and scan the annotations inside beans and activate them --><br />
<context:component-scan base-package="com.hibernate.spring" /><br />
<context:component-scan base-package="com.hibernate.spring.controller" /><br />
<br />
<!-- This allow for dispatching requests to Controllers --><br />
<mvc:annotation-driven /><br />
<br />
<!-- This helps in mapping the logical view names to directly view files under a certain pre-configured directory --><br />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><br />
<property name="prefix" value="/WEB-INF/views/" /><br />
<property name="suffix" value=".jsp" /><br />
</bean><br />
<br />
<!-- This produces a container-managed EntityManagerFactory;<br />
rather than application-managed EntityManagerFactory as in case of LocalEntityManagerFactoryBean--><br />
<bean id="entityManagerFactoryBean" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"><br />
<property name="dataSource" ref="dataSource" /><br />
<!-- This makes /META-INF/persistence.xml is no longer necessary --><br />
<property name="packagesToScan" value="com.hibernate.spring.domain" /><br />
<!-- JpaVendorAdapter implementation for Hibernate EntityManager.<br />
Exposes Hibernate's persistence provider and EntityManager extension interface --><br />
<property name="jpaVendorAdapter"><br />
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" /><br />
</property><br />
<property name="jpaProperties"><br />
<props><br />
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop><br />
</props><br />
</property><br />
</bean><br />
<br />
<!-- Simple implementation of the standard JDBC DataSource interface,<br />
configuring the plain old JDBC DriverManager via bean properties --><br />
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"><br />
<property name="driverClassName" value="oracle.jdbc.OracleDriver" /><br />
<property name="url" value="jdbc:oracle:thin:@172.20.1.47:1521:XE" /><br />
<property name="username" value="DLAUDIT" /><br />
<property name="password" value="DLAUDIT" /><br />
</bean><br />
<br />
<!-- This transaction manager is appropriate for applications that use a single JPA EntityManagerFactory for transactional data access.<br />
JTA (usually through JtaTransactionManager) is necessary for accessing multiple transactional resources within the same transaction. --><br />
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"><br />
<property name="entityManagerFactory" ref="entityManagerFactoryBean" /><br />
</bean><br />
<br />
<!-- responsible for registering the necessary Spring components that power annotation-driven transaction management;<br />
such as when @Transactional methods are invoked --><br />
<tx:annotation-driven /><br />
<br />
</beans></div>
Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-43924830024569673612017-06-25T22:39:00.001+05:302017-06-25T22:39:14.641+05:30Find Type Of Object By Data or Itself<div dir="ltr" style="text-align: left;" trbidi="on">
package com.test;<br />
<br />
public class FindType {<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static void main(String[] args) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(findTypeOfObject("10"));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(findTypeOfObject(10));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(findTypeOfObject(10.00));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static String findTypeOfObject(Object object){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>String type = null;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (object != null ) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>type = object.getClass().getName();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return type;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
}<br />
<div>
<br /></div>
</div>
Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-92185416996713146612017-06-25T22:30:00.003+05:302017-06-25T22:30:47.652+05:30Transpose Matrix<div dir="ltr" style="text-align: left;" trbidi="on">
package com.test;<br />
<br />
import java.util.ArrayList;<br />
import java.util.List;<br />
<br />
public class Transpose {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static void main(String[] args) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<List<String>> data = getData();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("\n--------------------------Before Transpoese------------------------");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (int row = 0; row < data.size(); row++) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> colLst = data.get(row);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(" ");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (int i = 0; i < colLst.size(); i++) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>String cell = colLst.get(i);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.print(" "+cell);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("\n--------------------------After Transpoese------------------------");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<List<String>> transposedData = transposeData(data);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (int row = 0; row < transposedData.size(); row++) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> colLst = transposedData.get(row);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(" ");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (int i = 0; i < colLst.size(); i++) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>String cell = colLst.get(i);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.print(" "+cell);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static List<List<String>> transposeData(List<List<String>> data){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> rowList = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<List<String>> colList = new ArrayList<List<String>>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (int row = 0; row < data.get(0).size(); row++) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>rowList = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (int col = 0; col < data.size(); col++) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>String d = data.get(col).get(row);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>rowList.add(d);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>colList.add(rowList);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return colList;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static List<List<String>> getData(){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<List<String>> data = new ArrayList<List<String>>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("1");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("A");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("0");<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("-");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("2");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("B");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("1");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("-");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("3");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("C");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("1");<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("4");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("D");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("2");<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("5");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("E");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("2");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("6");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("F");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("3");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("7");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("G");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("3");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("8");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("H");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("7");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("9");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("I");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("7");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return data;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
}<br />
<div>
<br /></div>
</div>
Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-1091343197519968902017-06-22T08:22:00.000+05:302017-06-22T08:22:12.795+05:30<div dir="ltr" style="text-align: left;" trbidi="on">
package com.test;<br />
<br />
import java.util.ArrayList;<br />
import java.util.HashMap;<br />
import java.util.List;<br />
import java.util.Map;<br />
<br />
public class TestService {<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>static Map<String, String> mapN = new HashMap<String, String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>static int max_depth = 0;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static void main(String[] args) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<List<String>> data = getData();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(data);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Map<String, List<String>> mapP = new HashMap<String, List<String>>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (int i = 0; i < data.size(); i++) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> rows = data.get(i);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(mapP.get(rows.get(2)) != null){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> listC = mapP.get(rows.get(2));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>listC.add(rows.get(0));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>mapN.put(rows.get(0), rows.get(1));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> listC = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>listC.add(rows.get(0));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>mapN.put(rows.get(0), rows.get(1));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>mapP.put(rows.get(2), listC);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<List<String>> level_list = new ArrayList<List<String>>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<List<String>> final_list = new ArrayList<List<String>>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> first_level = mapP.get("0");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> this_level_list = new ArrayList<>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>loopingLowerLevel(first_level, mapP, 1, level_list, this_level_list);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for(int i = 0; i < level_list.size(); i++){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> list = level_list.get(i);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for(int j = 0; j < max_depth; j++){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(j >= list.size()){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(i == 0){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> list_d = new ArrayList<>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>list_d.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>final_list.add(list_d);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> list_dd = final_list.get(j);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>list_dd.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>final_list.set(j, list_dd);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(i == 0){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> list_d = new ArrayList<>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>list_d.add(list.get(j));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>final_list.add(list_d);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> list_dd = final_list.get(j);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>list_dd.add(list.get(j));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>final_list.set(j, list_dd);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> }<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for(int finall = 0; finall < final_list.size(); finall++){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(final_list.get(finall));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static void loopingLowerLevel(List<String> low_level_list, Map<String, List<String>> mapP, int level, List<List<String>> level_list, List<String> tree){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for(int i = 0; i < low_level_list.size(); i++){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> another_level_list = mapP.get(low_level_list.get(i));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> this_level_list = new ArrayList<>(tree);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>this_level_list.add(mapN.get(low_level_list.get(i)));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(another_level_list != null){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>loopingLowerLevel(another_level_list, mapP, (level+1), level_list, this_level_list);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>level_list.add(this_level_list);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(level > max_depth)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>max_depth = level;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>/*private static int loopingLowerLevel(List<String> low_level_list, Map<String, List<String>> mapP, String parent, int level, List<List<String>> level_list){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for(int i = 0; i < low_level_list.size(); i++){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> another_level_list = mapP.get(low_level_list.get(i));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(level_list.size() > level) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> list_p = level_list.get(level);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>list_p.add(mapN.get(low_level_list.get(i)));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>level_list.add(level, list_p);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> list_p = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>list_p.add(mapN.get(low_level_list.get(i)));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>level_list.add(level, list_p);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(another_level_list != null){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>int rtnLevel = loopingLowerLevel(another_level_list, mapP, low_level_list.get(i), level++, level_list);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}*/<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static List<List<String>> getData(){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<List<String>> data = new ArrayList<List<String>>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<String> dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("1");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("A");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("0");<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("2");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("B");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("1");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("3");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("C");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("1");<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("4");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("D");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("2");<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("5");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("E");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("2");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("6");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("F");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("3");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow = new ArrayList<String>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("7");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("G");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("3");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>dataRow.add("");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(dataRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return data;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
}<br />
<div>
<br /></div>
</div>
Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-70908174034234978332017-06-08T01:05:00.002+05:302017-06-08T01:05:13.333+05:30Super Model<div dir="ltr" style="text-align: left;" trbidi="on">
<H3>SuperModel</H3><br />
<br />
package com.test;<br />
<br />
import java.util.List;<br />
<br />
public class SuperModel {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private String data;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private String dataType;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private String name;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private String id;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private String cssClass;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private int rowSpan = 1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private int colSpan = 1;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<SuperModel> childSuperModel;<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public String getData() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return data;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void setData(String data) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.data = data;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public String getDataType() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return dataType;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void setDataType(String dataType) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.dataType = dataType;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public String getName() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return name;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void setName(String name) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.name = name;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public String getId() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return id;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void setId(String id) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.id = id;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public String getCssClass() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return cssClass;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void setCssClass(String cssClass) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.cssClass = cssClass;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public int getRowSpan() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return rowSpan;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void setRowSpan(int rowSpan) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.rowSpan = rowSpan;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public int getColSpan() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return colSpan;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void setColSpan(int colSpan) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.colSpan = colSpan;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public List<SuperModel> getChildSuperModel() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return childSuperModel;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void setChildSuperModel(List<SuperModel> childSuperModel) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>this.childSuperModel = childSuperModel;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>@Override<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public String toString() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return "SuperModel [data=" + data + ", dataType=" + dataType + ", name=" + name + ", id=" + id + ", cssClass="<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ cssClass + ", rowSpan=" + rowSpan + ", colSpan=" + colSpan + ", childSuperModel=" + childSuperModel<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ "]";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
}<br />
<div>
<br /></div>
<div>
<div>
package com.test;</div>
<div>
<br /></div>
<div>
import org.springframework.beans.factory.annotation.Autowired;</div>
<div>
import org.springframework.stereotype.Controller;</div>
<div>
import org.springframework.web.bind.annotation.RequestMapping;</div>
<div>
import org.springframework.web.servlet.ModelAndView;</div>
<div>
<br /></div>
<div>
@Controller</div>
<div>
public class SuperModelTestController {</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>@Autowired</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>SuperModelService superModelService;</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>@RequestMapping("getSuperModelView.htm")</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>public ModelAndView getSuperModelView(){</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>ModelAndView view = new ModelAndView("superModelView");</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>SuperModel superModelTable = superModelService.getSuperModelData();</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>view.addObject("superModelTable", superModelTable);</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>return view;</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div>
<br /></div>
<div>
}</div>
</div>
<div>
<br /></div>
<br />
package com.test;<br />
<br />
import java.util.ArrayList;<br />
import java.util.List;<br />
<br />
import org.springframework.stereotype.Service;<br />
<br />
@Service<br />
public class SuperModelServiceImpl implements SuperModelService {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private List<List<Object>> getData(){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<List<Object>> data = new ArrayList<List<Object>>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (int i = 0; i < 10; i++) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<Object> row = new ArrayList<Object>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (int j = 0; j < 5; j++) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Object obj = "Cell-"+i+"-"+j;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>row.add(obj);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>data.add(row);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(data);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return data;<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>@Override<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public SuperModel getSuperModelData() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<List<Object>> data = getData();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>SuperModel superModelTable = new SuperModel();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<SuperModel> superModelTableList = null;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(data != null && !data.isEmpty()){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>superModelTableList = new ArrayList<SuperModel>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>SuperModel superModelRow = new SuperModel();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (List<Object> listObj : data) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<SuperModel> superModelRowList = new ArrayList<SuperModel>();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (Object object : listObj) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>SuperModel superModelCell = new SuperModel();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>superModelCell.setData(object+"");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>superModelRowList.add(superModelCell);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>superModelRow.setChildSuperModel(superModelRowList);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>superModelTableList.add(superModelRow);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>superModelTable.setChildSuperModel(superModelTableList);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(superModelTable);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return superModelTable;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
}<br />
<div>
<br /></div>
<div>
<br /></div>
<div>
<div>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"</div>
<div>
pageEncoding="ISO-8859-1"%></div>
<div>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"></div>
<div>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> </div>
<div>
<html></div>
<div>
<head></div>
<div>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></div>
<div>
<title>Insert title here</title></div>
<div>
</head></div>
<div>
<body></div>
<div>
<table></div>
<div>
<c:forEach items="${superModelTable.childSuperModel}" var="superModelTableList"></div>
<div>
<tr></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><c:forEach items="${superModelTableList.childSuperModel}" var="superModelRow"></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><td></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><c:out value="${superModelRow.data}"></c:out></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span></td></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span></c:forEach></div>
<div>
</tr></div>
<div>
</c:forEach></div>
<div>
</table></div>
<div>
</body></div>
<div>
</html></div>
</div>
</div>
Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-92118597295920521892012-10-10T00:35:00.004+05:302012-10-10T00:35:50.963+05:30Complex Element<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="text-align: center;">
<b>Complex Element</b></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Complex Element : which element contains simple elements or
other complex elements is call complex element.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
We can create complex elements in two ways in xsd</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
1.creating complex type elements and using them</div>
<div class="MsoNormal">
2.annoums complex element</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
1.creating complex type elements and using them</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
we can create a complex element in xsd by using
"complexType" key word </div>
<div class="MsoNormal">
as follows </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
we can resue the structure of the complex type (it is
creating class in java)</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
compareing java class and complex type in xsd.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;">
<tbody>
<tr>
<td style="border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 239.4pt;" valign="top" width="319">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
Class in java</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
</td>
<td style="border-left: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 239.4pt;" valign="top" width="319">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
Complex Type in xsd</div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 239.4pt;" valign="top" width="319">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
Class name_of_class</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
{</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
//statements </div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
}</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 239.4pt;" valign="top" width="319">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<complexType name=”name_of_complex _type”></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<sequence/all></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
//simple
elements</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
</sequence/all></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
</complexType></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 239.4pt;" valign="top" width="319">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
class ItemType</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
{</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
String itemcode;</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
int quantity;</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
}</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 239.4pt;" valign="top" width="319">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<complexType name="itemtype"></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<sequance></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<element
name="itemcode" type="string"/></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<element
name="quantity" type="int"/></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
</sequance></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
</complexType></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
</td>
</tr>
<tr>
<td style="border-top: none; border: solid black 1.0pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 239.4pt;" valign="top" width="319">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
ItemType item=new ItemType();</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
</td>
<td style="border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 239.4pt;" valign="top" width="319">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<element name=”item” type=”itemtype”></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Structure: </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<complexType name="complex_type_name"></div>
<div class="MsoNormal">
<sequance/all></div>
<div class="MsoNormal">
//simple
elements or complex elements</div>
<div class="MsoNormal">
</sequance/all></div>
<div class="MsoNormal">
</complexType></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Example:</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
complexType which contains simple elements</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<complexType name="itemtype"></div>
<div class="MsoNormal">
<sequance></div>
<div class="MsoNormal">
<element
name="itemcode" type="string"/></div>
<div class="MsoNormal">
<element
name="quantity" type="int"/></div>
<div class="MsoNormal">
</sequance></div>
<div class="MsoNormal">
</complexType></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
complexType which contains complex elements</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<complexType name="orderitemstype"></div>
<div class="MsoNormal">
<sequance></div>
<div class="MsoNormal">
<element
name="quantity" type="itemtype"/></div>
<div class="MsoNormal">
</sequance></div>
<div class="MsoNormal">
</complexType></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
</div>
Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-46176436189491779632012-10-10T00:31:00.001+05:302012-10-10T00:34:13.069+05:30XML Well Form<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
XML Well Form</div>
<div class="MsoNormal">
For well formed XML we follow the following rules.</div>
<div class="MsoNormal">
Well form talks about the structure of the xml document</div>
<div class="MsoNormal">
Rules:</div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->XML file should start with prolog (optional)</div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->Only one root tag is allowed</div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->All the elements (tags) must be under Root Tag
only</div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->Every stating tag must have ending tag (closing
tag)</div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->The level of opening tag must be closed the same
level</div>
<div class="MsoListParagraphCxSpLast" style="mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: 'Times New Roman'; font-size: 7pt;">
</span></span><!--[endif]-->XML tags are case sensitive i.e <Tag> and <tag> both are
treated as different tags</div>
<div class="MsoNormal">
Demo:</div>
<div class="MsoNormal">
File Name: Demo.xml</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; color: teal; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"><?xml version="1.0" encoding="UTF-8"?></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"><</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">PURCHAGEORDER</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">> <!- root tag opening at level 0 --></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"><</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">ORDERITEMS</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">> <!- opening tag at level 1 --></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"><</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">ITEM</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">> <!-
opening tag at level 2 --></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"><</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">ITEMCODE</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;">NOKIA345</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"></</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">ITEMCODE</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"><</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">QUANTITY</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;">6</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"></</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">QUANTITY</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"></</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">ITEM</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">><!- closing tag at level 2 --></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"></</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">ORDERITEMS</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">> <!- closing tag at level 1 --></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"><</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">SHIPPINGADDRESS</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">><!- opening tag at level 1 --></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"><</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">ADDR</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;">SAN</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"></</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">ADDR</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">><!- opening and closing tag at level 2 --></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"><</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">DORNO</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;">77-98</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"></</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">DORNO</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">><!- opening and closing tag at level 2 --></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"><</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">STREAT</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;">GOPALNAGAR</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"></</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">STREAT</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">><!- opening and closing tag at level 2 --></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"><</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">CITY</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;">HYD</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"></</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">CITY</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">><!- opening and closing tag at level 2 --></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"> </span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;"></</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">SHIPPINGADDRESS</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; mso-highlight: white;">><!- closing tag at level 1 --></span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-highlight: white;"></</span><span style="background: white; color: maroon; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-highlight: white;">PURCHAGEORDER</span><span style="background: white; color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-highlight: white;">><!- closing tag at
level 0 --></span><span style="color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Note: above demo.xml file satisfy’s all the
rules so its call well formed xml<o:p></o:p></span></div>
<div class="MsoListParagraph" style="mso-list: l1 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-fareast-font-family: Arial;">1.<span style="font-family: 'Times New Roman'; font-size: 7pt; line-height: normal;"> </span></span><!--[endif]--><span style="color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">For checking is well formed or not open in the browser, if its
shows the above content as it we wrote <o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: .5in;">
<span style="color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">Otherwise it
shows the error where and what<o:p></o:p></span></div>
<div class="MsoListParagraph" style="mso-list: l1 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%; mso-fareast-font-family: Arial;">2.<span style="font-family: 'Times New Roman'; font-size: 7pt; line-height: normal;"> </span></span><!--[endif]--><span style="color: blue; font-family: "Arial","sans-serif"; font-size: 9.0pt; line-height: 115%;">use the xml spy tool check whether the xml is well formed or not<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
</div>
Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-7865211414205996932012-10-10T00:23:00.003+05:302012-10-10T00:23:32.853+05:30SIMPLE WEB SERVICE PROVIDER SIDE APPLICATION<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div align="center" class="MsoNormal" style="text-align: center;">
<b>SIMPLE WEB SERVICE
PROVIDER SIDE APPLICATION</b></div>
<div class="MsoNormal">
Requirement:</div>
<div class="MsoNormal">
Develop
a web service provider side application which, provide complete information
about a book by giving a book name as input.</div>
<div class="MsoNormal">
Web service development environment:</div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l1 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->1.<span style="font-size: 7pt;">
</span><!--[endif]-->Using Jax-rpc api si (sun implementation) </div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->2.<span style="font-size: 7pt;">
</span><!--[endif]-->Contract as last</div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->3.<span style="font-size: 7pt;">
</span><!--[endif]-->Synchronous reply/response message exchange
pattern </div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->4.<span style="font-size: 7pt;">
</span><!--[endif]-->rpc-encoded </div>
<div class="MsoListParagraphCxSpLast" style="mso-list: l1 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]-->5.<span style="font-size: 7pt;">
</span><!--[endif]-->servlet end-point </div>
<div class="MsoNormal">
Software requirements:</div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]-->1.<span style="font-size: 7pt;">
</span><!--[endif]-->java 1.5.0_22and java 1.6.0 in between</div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]-->2.<span style="font-size: 7pt;">
</span><!--[endif]-->jax-rpc specific jar files</div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]-->3.<span style="font-size: 7pt;">
</span><!--[endif]--> apache-
tomcat 6.x serve</div>
<div class="MsoListParagraphCxSpLast" style="mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]-->4.<span style="font-size: 7pt;">
</span><!--[endif]-->Jwsdp 2.0 tool</div>
<div class="MsoNormal">
Development procedure:</div>
<div class="MsoNormal">
Step 1:</div>
<div class="MsoNormal">
Create
a dynamic project in eclipse as follows.</div>
<div class="MsoNormal">
File->New->Others->Dynamic web project</div>
<div class="MsoNormal">
Give the project name and set server as tomcat </div>
<div class="MsoNormal" style="text-indent: .5in;">
project Name: bookproject</div>
<div class="MsoNormal">
Create a package under project : bookproject as shown </div>
<div class="MsoNormal" style="text-indent: .5in;">
Package name: com.bookweb.service</div>
<div class="MsoNormal">
Step 2:</div>
<div class="MsoNormal">
Copy
the all jax-rpc specific jar files into lib folder.</div>
<div class="MsoNormal">
Step 3:</div>
<div class="MsoNormal">
Create
a SEI interface as follows </div>
<div class="MsoNormal">
Interface
name: <span style="font-family: Consolas; font-size: 10pt; line-height: 115%;">BookInterface</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">package</span></b><span style="font-family: Consolas; font-size: 10pt;"> com.bookweb.service;</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">import</span></b><span style="font-family: Consolas; font-size: 10pt;"> java.rmi.Remote;</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">import</span></b><span style="font-family: Consolas; font-size: 10pt;">
java.rmi.RemoteException;</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="font-family: Consolas; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">interface</span></b><span style="font-family: Consolas; font-size: 10pt;"> BookInterface </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">extends</span></b><span style="font-family: Consolas; font-size: 10pt;"> Remote {</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> </span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">float</span></b><span style="font-family: Consolas; font-size: 10pt;"> getBookPrice(String
isbn) </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">throws</span></b><span style="font-family: Consolas; font-size: 10pt;"> RemoteException;</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;">}</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Step 4:</div>
<div class="MsoNormal">
Implemented
class name: <span style="font-family: Consolas; font-size: 10pt; line-height: 115%;">BookImpl.java</span></div>
<div class="MsoNormal">
Provide
implementation for SEI interface, which is full fill our business requirements </div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">package</span></b><span style="font-family: Consolas; font-size: 10pt;"> com.bookweb.service;</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">import</span></b><span style="font-family: Consolas; font-size: 10pt;">
java.rmi.RemoteException;</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="font-family: Consolas; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">class</span></b><span style="font-family: Consolas; font-size: 10pt;"> BookImpl </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">implements</span></b><span style="font-family: Consolas; font-size: 10pt;"> BookInterface {</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">public</span></b><span style="font-family: Consolas; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">float</span></b><span style="font-family: Consolas; font-size: 10pt;"> getBookPrice(String
isbn) </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">throws</span></b><span style="font-family: Consolas; font-size: 10pt;"> RemoteException {</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">float</span></b><span style="font-family: Consolas; font-size: 10pt;"> bookprice=0.0f;</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">if</span></b><span style="font-family: Consolas; font-size: 10pt;">(isbn.equals(</span><span style="color: #2a00ff; font-family: Consolas; font-size: 10.0pt;">"java"</span><span style="font-family: Consolas; font-size: 10pt;">))</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> bookprice=234.56f;</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: Consolas; font-size: 10.0pt;">return</span></b><span style="font-family: Consolas; font-size: 10pt;"> bookprice;</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> }</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;">Step 5:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> </span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
Write a configuration
file under WEB-INF folder as following tags </div>
<div class="MsoNormal">
Configuration file name: config.xml</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: teal; font-family: Consolas; font-size: 10.0pt;"><?</span><span style="color: #3f7f7f; font-family: Consolas; font-size: 10.0pt;">xml</span><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">version</span>=<i><span style="color: #2a00ff;">"1.0"</span></i>
<span style="color: #7f007f;">encoding</span>=<i><span style="color: #2a00ff;">"UTF-8"</span></i><span style="color: teal;">?></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: teal; font-family: Consolas; font-size: 10.0pt;"><</span><span style="color: #3f7f7f; font-family: Consolas; font-size: 10.0pt;">configuration</span><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">xmlns</span>=<i><span style="color: #2a00ff;">"http://java.sun.com/xml/ns/jax-rpc/ri/config"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> </span><span style="color: teal; font-family: Consolas; font-size: 10.0pt;"><</span><span style="color: #3f7f7f; font-family: Consolas; font-size: 10.0pt;">service</span><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">name</span>=<i><span style="color: #2a00ff;">"BookInfoService"</span></i>
<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">targetNamespace</span>=<i><span style="color: #2a00ff;">"http://bookinfoservice.org/wsdl"</span></i><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">typeNamespace</span>=<i><span style="color: #2a00ff;">"http://bookinfoservice.org/types"</span></i> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">packageName</span>=<i><span style="color: #2a00ff;">"com.bookweb.service.binding"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> </span><span style="color: teal; font-family: Consolas; font-size: 10.0pt;"><</span><span style="color: #3f7f7f; font-family: Consolas; font-size: 10.0pt;">interface</span><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">name</span>=<i><span style="color: #2a00ff;">"com.bookweb.service.BookInterface"</span></i><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">servantName</span>=<i><span style="color: #2a00ff;">"com.bookweb.service.BookImpl"</span></i> <span style="color: teal;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> </span><span style="color: teal; font-family: Consolas; font-size: 10.0pt;"></</span><span style="color: #3f7f7f; font-family: Consolas; font-size: 10.0pt;">service</span><span style="color: teal; font-family: Consolas; font-size: 10.0pt;">></span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: teal; font-family: Consolas; font-size: 10.0pt; line-height: 115%;"></</span><span style="color: #3f7f7f; font-family: Consolas; font-size: 10.0pt; line-height: 115%;">configuration</span><span style="color: teal; font-family: Consolas; font-size: 10.0pt; line-height: 115%;">><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Step 5: </div>
<div class="MsoNormal">
Install
jwsdp2.0 tool</div>
<div class="MsoNormal">
Set path for bin as C:\Sun\jwsdp-2.0\jaxrpc\bin</div>
<div class="MsoNormal">
Run wscompile.bat with following options and pass config.xml
as input</div>
<div class="MsoNormal">
C:\Users\sant\workspace\BookService>wscompile -keep -verbose
-gen:server -d src</div>
<div class="MsoNormal">
-cp build\classes -model model-rpc-enc.xml.gz
WebContent\WEB-INF\config.xml</div>
<div class="MsoNormal">
It will generates wsdl file and model files and saxparsers
and java classes</div>
<div class="MsoNormal">
Move the wsdl and model file into WEB-INF folder </div>
<div class="MsoNormal">
Step 5:</div>
<div class="MsoNormal">
Write
one more configuration file jax-rpc.xml (file name with same name only) under
WEB-INF</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: teal; font-family: Consolas; font-size: 10.0pt;"><?</span><span style="color: #3f7f7f; font-family: Consolas; font-size: 10.0pt;">xml</span><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">version</span>=<i><span style="color: #2a00ff;">"1.0"</span></i>
<span style="color: #7f007f;">encoding</span>=<i><span style="color: #2a00ff;">"UTF-8"</span></i><span style="color: teal;">?></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: teal; font-family: Consolas; font-size: 10.0pt;"><</span><span style="color: #3f7f7f; font-family: Consolas; font-size: 10.0pt;">webServices</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">xmlns</span>=<i><span style="color: #2a00ff;">"http://java.sun.com/xml/ns/jax-rpc/ri/dd"</span></i><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">version</span>=<i><span style="color: #2a00ff;">"1.0"</span></i><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">targetNamespaceBase</span>=<i><span style="color: #2a00ff;">"http://bookinfoservice.org/wsdl"</span></i><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">typeNamespaceBase</span>=<i><span style="color: #2a00ff;">"http://bookinfoservice.org/types"</span></i><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">urlPatternBase</span>=<i><span style="color: #2a00ff;">"/getBookPrice"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;">
</span><span style="color: teal; font-family: Consolas; font-size: 10.0pt;"><</span><span style="color: #3f7f7f; font-family: Consolas; font-size: 10.0pt;">endpoint</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">name</span>=<i><span style="color: #2a00ff;">"booksriceservice"</span></i><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">displayName</span>=<i><span style="color: #2a00ff;">"Book Service"</span></i><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">description</span>=<i><span style="color: #2a00ff;">"A simple web service"</span></i> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">wsdl</span>=<i><span style="color: #2a00ff;">"/WEB-INF/BookInfoService.wsdll"</span></i><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">interface</span>=<i><span style="color: #2a00ff;">"com.bookweb.service.BookInterface"</span></i> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">implementation</span>=<i><span style="color: #2a00ff;">"com.bookweb.service.BookImpl"</span></i> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">model</span>=<i><span style="color: #2a00ff;">"/WEB-INF/model-rpc-enc.xml.gz"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> </span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;"> </span><span style="color: teal; font-family: Consolas; font-size: 10.0pt;"></</span><span style="color: #3f7f7f; font-family: Consolas; font-size: 10.0pt;">endpoint</span><span style="color: teal; font-family: Consolas; font-size: 10.0pt;">></span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10pt;">
</span><span style="color: teal; font-family: Consolas; font-size: 10.0pt;"><</span><span style="color: #3f7f7f; font-family: Consolas; font-size: 10.0pt;">endpointMapping</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">endpointName</span>=<i><span style="color: #2a00ff;">"booksriceservice"</span></i><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: #7f007f;">urlPattern</span>=<i><span style="color: #2a00ff;">"/getBookPrice"</span></i><span style="color: teal;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: teal; font-family: Consolas; font-size: 10.0pt;"></</span><span style="color: #3f7f7f; font-family: Consolas; font-size: 10.0pt;">webServices</span><span style="color: teal; font-family: Consolas; font-size: 10.0pt;">></span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Step 6:</div>
<div class="MsoNormal">
Export
project as .war file </div>
<div class="MsoNormal">
Give the war as input to the wsdeploy.bat </div>
<div class="MsoNormal">
C:\wsdeploy –o taget.war bookproject.war</div>
<div class="MsoNormal">
It generates the jax-rpc-runtime.xml and web.xml</div>
<div class="MsoNormal">
Copy the same file into the project WEB-INF folder </div>
<div class="MsoNormal">
Step 7:</div>
<div class="MsoNormal">
Deploy the project in server and run the server and provide
the url;</div>
<div class="MsoNormal">
url : <a href="http://localhost:8080/bookproject/getBookPrice">http://localhost:8080/bookproject/getBookPrice</a></div>
<div class="MsoNormal">
output as follows:</div>
<div class="MsoNormal">
<b><span style="font-family: 'Times New Roman', serif; font-size: 24pt;">Web Services<o:p></o:p></span></b></div>
<table border="1" cellpadding="0" class="MsoNormalTable" style="mso-cellspacing: 1.5pt; mso-yfti-tbllook: 1184; width: 106%px;">
<tbody>
<tr style="height: 13.6pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="height: 13.6pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Port Name<o:p></o:p></span></div>
</td>
<td style="height: 13.6pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Status<o:p></o:p></span></div>
</td>
<td style="height: 13.6pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Information<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 158.25pt; mso-yfti-irow: 1; mso-yfti-lastrow: yes;">
<td style="height: 158.25pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">booksriceservice<o:p></o:p></span></div>
</td>
<td style="height: 158.25pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">ACTIVE<o:p></o:p></span></div>
</td>
<td style="height: 158.25pt; padding: .75pt .75pt .75pt .75pt;">
<table border="0" cellpadding="0" class="MsoNormalTable" style="margin-left: .05pt; mso-cellspacing: 1.5pt; mso-yfti-tbllook: 1184; width: 482px;">
<tbody>
<tr style="height: 14.25pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="height: 14.25pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Address:<o:p></o:p></span></div>
</td>
<td style="height: 14.25pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">http://localhost:8080/bookproject/getBookPrice<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 27.9pt; mso-yfti-irow: 1;">
<td style="height: 27.9pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">WSDL:<o:p></o:p></span></div>
</td>
<td style="height: 27.9pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<a href="http://localhost:8080/bookproject/getBookPrice?WSDL"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">http://localhost:8080/bookproject/getBookPrice?WSDL</span></a><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 14.25pt; mso-yfti-irow: 2;">
<td style="height: 14.25pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Port QName:<o:p></o:p></span></div>
</td>
<td style="height: 14.25pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">{http://bookinfoservice.org/wsdl}BookInterfacePort<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 27.9pt; mso-yfti-irow: 3;">
<td style="height: 27.9pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Remote interface:<o:p></o:p></span></div>
</td>
<td style="height: 27.9pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">com.bookweb.service.BookInterface<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 27.9pt; mso-yfti-irow: 4;">
<td style="height: 27.9pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Implementation class:<o:p></o:p></span></div>
</td>
<td style="height: 27.9pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">com.bookweb.service.BookImpl<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 28.55pt; mso-yfti-irow: 5; mso-yfti-lastrow: yes;">
<td style="height: 28.55pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">Model:<o:p></o:p></span></div>
</td>
<td style="height: 28.55pt; padding: .75pt .75pt .75pt .75pt;">
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<a href="http://localhost:8080/bookproject/getBookPrice?model"><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";">http://localhost:8080/bookproject/getBookPrice?model</span></a><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<div class="MsoNormal">
<br /></div>
</div>
Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-30846586735953340792012-05-19T10:16:00.000+05:302012-05-19T10:16:03.350+05:30<div dir="ltr" style="text-align: left;" trbidi="on">
<h2 style="text-align: center;">
<b>public access modifier</b></h2>
<div style="text-align: left;">
<b>RULE: </b>public is key word and it is an access modifier, we can apply this modifier for classes,methods and variables .</div>
<div style="text-align: left;">
we can access from the program and out side of the program of out side packages.</div>
<div style="text-align: left;">
Recommended for classes and method but not variables.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Demo:</div>
<div style="text-align: left;">
package demo.publ;</div>
<div style="text-align: left;">
public class DemoPublic</div>
<div style="text-align: left;">
{</div>
<div style="text-align: left;">
public methodDemo</div>
<div style="text-align: left;">
{</div>
<div style="text-align: left;">
System.out.println("public method in demo.publi.Demopublic");</div>
<div style="text-align: left;">
}</div>
<div style="text-align: left;">
}</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
package demo.pub2;</div>
<div style="text-align: left;">
import demo.publi.DemoPublic;</div>
<div style="text-align: left;">
public class UsePublic</div>
<div style="text-align: left;">
{</div>
<div style="text-align: left;">
public static void main(String at[])</div>
<div style="text-align: left;">
{</div>
<div style="text-align: left;">
Demopublic p=new Demopublic();</div>
<div style="text-align: left;">
p.methodDemo();</div>
<div style="text-align: left;">
}</div>
<div style="text-align: left;">
}</div>
</div>Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-73254454558945819972012-04-18T15:05:00.001+05:302012-04-18T15:05:06.637+05:30multiple upload files<div dir="ltr" style="text-align: left;" trbidi="on">
package com.mp.ws;<br /><br /> /**<br /> *<br /> * @author nitinaggarwal<br /> *<br /> */<br /> public interface IFileUpload {<br /><br /> public byte[] get1File(String name);<br /><br /> public byte[][] getMulitpleFiles(String names[]);<br /><br /> public String getXmlFile(String name);<br /><br /> }<br /><br /> package com.mp.ws;<br /><br /> /**<br /> *<br /> * @author nitinaggarwal<br /> *<br /> */<br /> public class FileUpload implements IFileUpload {<br /><br /> public byte[] get1File(String name) {<br /> byte data[] = null;<br /><br /> FileReader fr = new FileReader();<br /> try {<br /> data = fr.readBinFilePath(name);<br /> } catch (Exception e) {<br /> e.printStackTrace();<br /> }<br /><br /> return data;<br /> }<br /><br /> public String getXmlFile(String name) {<br /> String data = null;<br /> FileReader fr = new FileReader();<br /> try {<br /> data = fr.readTextFile(name);<br /> } catch (Exception e) {<br /> e.printStackTrace();<br /> }<br /> return data;<br /> }<br /><br /> public byte[][] getMulitpleFiles(String[] fnames) {<br /><br /> byte[][] data = new byte[fnames.length][];<br /> for (int i = 0; i < fnames.length; i++) {<br /> FileReader fr = new FileReader();<br /> try {<br /> data[i] = fr.readBinFilePath(fnames[i]);<br /><br /> System.out.println("abc" + data[i]);<br /> } catch (Exception e) {<br /> e.printStackTrace();<br /> }<br /> }<br /> return data;<br /> }<br /><br /> }<br /><br /> package com.mp.ws;<br /><br /> import java.io.FileInputStream;<br /> import java.io.FileNotFoundException;<br /> import java.io.FileOutputStream;<br /> import java.io.IOException;<br /> import java.io.InputStream;<br /> import java.io.InputStreamReader;<br /><br /> /**<br /> *<br /> * @author nitinaggarwal<br /> *<br /> */<br /> public class FileReader {<br /><br /> public String readTextFile(final String name) throws Exception {<br /> StringBuffer xmlFromFile = new StringBuffer();<br /> InputStream instr = null;<br /> //instr = getFilePath2(name);<br /><br /> instr = new FileInputStream(name);<br /><br /> if (instr == null)<br /> throw new FileNotFoundException();<br /> InputStreamReader streamreader = null;<br /><br /> try {<br /><br /> streamreader = new InputStreamReader(instr);<br /> int x = 0;<br /> x = streamreader.read();<br /><br /> while (x != -1) {<br /> xmlFromFile.append((char) x);<br /> x = streamreader.read();<br /><br /> }<br /><br /> } catch (Exception e) {<br /><br /> System.out.println("Exception " + e.getMessage());<br /> throw e;<br /><br /> } finally {<br /> streamreader.close();<br /><br /> }<br /><br /> return xmlFromFile.toString();<br /><br /> }<br /><br /> public byte[] readBinFileFromClassPath(final String name) throws Exception {<br /><br /> byte bytearray[] = null;<br /> FileInputStream fileinputstream = null;<br /> try {<br /><br /> fileinputstream = new FileInputStream(getFilePath(name));<br /> int numberBytes = fileinputstream.available();<br /> bytearray = new byte[numberBytes];<br /> fileinputstream.read(bytearray);<br /><br /> } catch (Exception e) {<br /> System.out.println("Exception " + e.getMessage());<br /> throw e;<br /><br /> } finally {<br /> if (fileinputstream != null)<br /> fileinputstream.close();<br /> }<br /><br /> return bytearray;<br /> }<br /><br /> public byte[] readBinFilePath(final String name) throws Exception {<br /><br /> byte bytearray[] = null;<br /> FileInputStream fileinputstream = null;<br /> try {<br /><br /> fileinputstream = new FileInputStream(name);<br /> int numberBytes = fileinputstream.available();<br /> bytearray = new byte[numberBytes];<br /> fileinputstream.read(bytearray);<br /><br /> } catch (Exception e) {<br /> System.out.println("Exception " + e.getMessage());<br /> throw e;<br /><br /> } finally {<br /> if (fileinputstream != null)<br /> fileinputstream.close();<br /> }<br /><br /> return bytearray;<br /> }<br /><br /> public void writeBinFileToPath(String name, byte data[]) throws IOException {<br /><br /> FileOutputStream fileoutputstream = new FileOutputStream(name);<br /><br /> try {<br /> fileoutputstream.write(data);<br /><br /> } catch (IOException e) {<br /> System.out.println(e.getMessage());<br /><br /> } finally {<br /> if (fileoutputstream != null)<br /> fileoutputstream.close();<br /> data = null;<br /> }<br /><br /> }<br /><br /> private InputStream getFilePath2(String filename) {<br /> return this.getClass().getClassLoader().getResourceAsStream(filename);<br /><br /> }<br /><br /> private String getFilePath(String filename) throws FileNotFoundException {<br /> String path = this.getClass().getClassLoader().getResource(filename)<br /> .getPath();<br /> if ("".equals(path))<br /> throw new FileNotFoundException();<br /> return path;<br /><br /> }<br /><br /> }<br /><br /> package com.mp.ws;<br /><br /> /**<br /> *<br /> * @author nitinaggarwal<br /> *<br /> */<br /> @javax.jws.WebService(targetNamespace = "http://ws.mp.com/", serviceName = "FileUploadService", portName = "FileUploadPort")<br /> public class FileUploadDelegate {<br /><br /> com.mp.ws.FileUpload fileUpload = new com.mp.ws.FileUpload();<br /><br /> public byte[] get1File(String name) {<br /> return fileUpload.get1File(name);<br /> }<br /><br /> public byte[][] getMulitpleFiles(String[] fnames) {<br /> return fileUpload.getMulitpleFiles(fnames);<br /> }<br /><br /> public String getXmlFile(String name) {<br /> return fileUpload.getXmlFile(name);<br /> }<br /><br /> }<br /><br /> package com.mp.ws;<br /> /**<br /> *<br /> * @author nitinaggarwal<br /> *<br /> */<br /> public class FileUploadTester {<br /><br /> public static void main(String[] args) {<br /> FileUpload fu = new FileUpload();<br /> String fnames[]= {"c:/uploadme.doc","c:/uploadme.doc","c:/uploadme.doc"};<br /><br /> byte[][] data = fu.getMulitpleFiles(fnames);<br /><br /> }<br /> }<br /></div>Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-77667660528981194542012-04-18T15:03:00.001+05:302012-04-18T15:03:41.032+05:30multiple file upload helpful website urls<div dir="ltr" style="text-align: left;" trbidi="on">
1. http://digitarald.de/project/fancyupload/ <br />
2. http://swfupload.org <br />3. http://jupload.sourceforge.net/<br />4. http://jumploader.com/<br />5. http://code.google.com/apis/gears/samples/hello_world_file_system.html<br />6. http://www.telerik.com/products/aspnet-ajax/upload.aspx#uploading-files<br />7. http://www.element-it.com/multiple-file-upload/flash-uploader.aspx<br />8. http://stackoverflow.com/questions/582126/best-way-to-upload-multiple-files-from-a-browser<br /></div>Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-3528826568936899682012-01-25T12:45:00.001+05:302012-05-19T09:51:29.949+05:30arithmetic operators<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
//arthemetic operators using switch</div>
<div style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
import java.io.*;</div>
<div style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
class Input2</div>
<div style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
{</div>
<div style="color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static void main(String[] args)throws IOException</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>char ch;</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>InputStreamReader ir=new InputStreamReader(System.in);</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>BufferedReader br=new BufferedReader(ir);</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("enter values of x");</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>int x=Integer.parseInt(br.readLine());</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("enter values of y");</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>int y=Integer.parseInt(br.readLine());</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("enter u r choice");</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("+ for additon");</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("- for subtraction");</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("/ for divide");</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("* for multipiy");</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("% for remainder");</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>ch=(char)br.read();</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>switch(ch)</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>case '+':</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("additon:"+(x+y));</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>break;</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>case '-':</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("sub:"+(x-y));</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>break;</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>case '*':</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("mul:"+(x*y));</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>break;</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>case '/':</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("divide:"+(x/y));</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>break;</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>case '%':</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("Remainder:"+(x%y));</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>break;</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
}</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
}</div>
</div>Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-72157283063609717872012-01-25T12:43:00.001+05:302012-05-19T09:53:05.405+05:30Reading an integer from keyboard<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
// input from key board</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
import java.io.*;</div>
<div style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
class Inputint</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
{</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static void main(String r[])throws IOException</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>{</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>InputStreamReader id=new InputStreamReader(System.in);</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>BufferedReader br=new BufferedReader(id);</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<br /></div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("enter a interger");</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<br /></div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>int s=Integer.parseInt(br.readLine());</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<br /></div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("enter "+s);</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">
}</div>
</div>Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-68356668409391108192012-01-25T12:38:00.001+05:302012-05-19T09:53:58.884+05:30reading a string from keyboard<div dir="ltr" style="text-align: left;" trbidi="on">
<span style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">// input from key board</span><br style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;" /><span style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">import java.io.*;</span><br style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;" /><span style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">class Inputstring</span><br style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;" /><span style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">{</span><br style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;" /><span style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">public static void main(String r[])throws IOException</span><br style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;" /><span style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">{</span><br style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;" /><span style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">//InputStreamReader id=new InputStreamReader(System.in);</span><br style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;" /><span style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">BufferedReader br=new BufferedReader(new InputStreamReader(System.in));</span><br style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;" /><span style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">System.out.println("enter a String vslue");</span><br style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;" /><span style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">String s=br.readLine();</span><br style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;" /><span style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">System.out.println("enter "+s);</span><br style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;" /><span style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">}</span><br style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;" /><span style=" color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px; text-align: -webkit-auto;">}</span>
</div>Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-52028095199283756772012-01-25T12:24:00.000+05:302012-05-19T09:55:04.697+05:30<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h3 class="post-title entry-title" style=" font: normal normal normal 30px/normal Molengo; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; position: relative; text-align: -webkit-auto;">
Simple AJAX Program</h3>
<div class="post-header" style=" color: #1d37ce; font-family: 'Times New Roman', Times, FreeSerif, serif; font-size: 15px; font-weight: bold; line-height: 1.6; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: -webkit-auto;">
<div class="post-header-line-1">
</div>
</div>
<div class="post-body entry-content" id="post-body-4958920189643772262" style=" font-family: 'Times New Roman', Times, FreeSerif, serif; font-size: 15px; font-weight: bold; line-height: 1.5; position: relative; text-align: -webkit-auto; width: 568px;">
<div dir="ltr" style="text-align: left;" trbidi="on">
<b>Simple AJAX application using java script and JSP.</b><br /><br /><br /><b>Files required.</b><br /><br />1. ajax.js<br />2. mainpage.jsp<br />3. process.jsp<br />4. web.xml<br /><br /><b>Code :</b><br /><b><br /></b><br /><b><span class="Apple-style-span" style="color: red;">1. ajax.js</span></b><br /><b><span class="Apple-style-span" style="color: red;"><br /></span></b><br /><br /><span class="Apple-style-span" style="color: blue;">var xmlHttp;</span><br /><span class="Apple-style-span" style="color: blue;">function postRequest(url) {</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">if (window.XMLHttpRequest) { // Mozilla, Safari, ...</span><br /><span class="Apple-style-span" style="color: blue;">//alert("other than IE");</span><br /><span class="Apple-style-span" style="color: blue;"> xmlHttp = new XMLHttpRequest();</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">} else if (window.ActiveXObject) { // IE</span><br /><span class="Apple-style-span" style="color: blue;">//alert("IE only");</span><br /><span class="Apple-style-span" style="color: blue;"> xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">}</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">xmlHttp.open('POST', url, true);</span><br /><span class="Apple-style-span" style="color: blue;">xmlHttp.onreadystatechange = function() {</span><span class="Apple-style-span" style="color: blue; white-space: pre;"> </span><br /><br /><span class="Apple-style-span" style="color: blue;">if (xmlHttp.readyState == 4) {</span><br /><span class="Apple-style-span" style="color: blue;">updatepage(xmlHttp.responseText);</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">}</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">}</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">xmlHttp.send(url);</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">}</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">function updatepage(str){</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">document.getElementById("result").innerHTML = </span><span class="Apple-style-span" style="color: blue;">"<font color='green' size='15'>" + str + "</font>";</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">}</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">function showCurrentTime(){</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">var url="process.jsp";</span><br /><span class="Apple-style-span" style="color: blue;">postRequest(url);</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">}</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><b><span class="Apple-style-span" style="color: red;">2. mainpage.jsp</span></b><br /><b><span class="Apple-style-span" style="color: red;"><br /></span></b><br /><br /><span class="Apple-style-span" style="color: blue;"><%@ page import="java.util.*" %></span><br /><span class="Apple-style-span" style="color: blue;"><html></span><br /><span class="Apple-style-span" style="color: blue;"><head></span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;"><title>Ajax Example</title></span><br /><span class="Apple-style-span" style="color: blue;"><script type="text/javascript" src="ajax.js"> </script></span><br /><span class="Apple-style-span" style="color: blue;"></head></span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;"><body></span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;"><h1 align="center"><font color="#000080">Ajax Example</font></h1></span><br /><span class="Apple-style-span" style="color: blue;"><%</span><br /><span class="Apple-style-span" style="color: blue;">out.println(new Date());</span><br /><span class="Apple-style-span" style="color: blue;">%></span><br /><span class="Apple-style-span" style="color: blue;"><p><font color="#000080">&nbsp;This very simple Ajax Example retrieves the</span><br /><span class="Apple-style-span" style="color: blue;">current date and time from server and shows on the form. To view the current</span><br /><span class="Apple-style-span" style="color: blue;">date and time click on the following button.</font></p></span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;"><form name="f1"></span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;"><p align="center"><font color="#000080">&nbsp;<input value=" Show Time " </span><br /><span class="Apple-style-span" style="color: blue;">type="button" onclick='JavaScript:showCurrentTime()' name="showdate"></font></p></span><br /><span class="Apple-style-span" style="color: blue;"><div id="result" align="center"></div></span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;"></form></span><br /><span class="Apple-style-span" style="color: blue;"><div id=result></div></span><br /><span class="Apple-style-span" style="color: blue;"></body></span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;"></html></span><br /><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><br /><b><span class="Apple-style-span" style="color: red;">3. process.jsp</span></b><br /><b><span class="Apple-style-span" style="color: red;"><br /></span></b><br /><br /><span class="Apple-style-span" style="color: blue;"><%@ page import="java.util.*" %></span><br /><span class="Apple-style-span" style="color: blue;"><%</span><br /><span class="Apple-style-span" style="color: blue;">out.println(new Date());</span><br /><span class="Apple-style-span" style="color: blue;">%></span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><b><span class="Apple-style-span" style="color: red;">4. web.xml</span></b><br /><b><span class="Apple-style-span" style="color: red;"><br /></span></b><br /><br /><span class="Apple-style-span" style="color: blue;"><?xml version="1.0" encoding="UTF-8"?></span><br /><span class="Apple-style-span" style="color: blue;"><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"></span><br /><span class="Apple-style-span" style="color: blue;"> <display-name>AjaxApp1</display-name></span><br /><span class="Apple-style-span" style="color: blue;"> </span><br /><span class="Apple-style-span" style="color: blue;"> <welcome-file-list></span><br /><span class="Apple-style-span" style="color: blue;"> <welcome-file>mainpage.jsp</welcome-file></span><br /><span class="Apple-style-span" style="color: blue;"> </span><br /><span class="Apple-style-span" style="color: blue;"> </welcome-file-list></span><br /><span class="Apple-style-span" style="color: blue;"></web-app></span></div>
</div>
</div>Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-56562085237841412632012-01-25T12:23:00.001+05:302012-05-19T09:56:10.280+05:30<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<h3 class="post-title entry-title" style=" font: normal normal normal 30px/normal Molengo; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; position: relative; text-align: -webkit-auto;">
Simple AJAX program with struts 1.2</h3>
<div class="post-header" style=" color: #1d37ce; font-family: 'Times New Roman', Times, FreeSerif, serif; font-size: 15px; font-weight: bold; line-height: 1.6; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: -webkit-auto;">
<div class="post-header-line-1">
</div>
</div>
<div class="post-body entry-content" id="post-body-3546666181484668925" style=" font-family: 'Times New Roman', Times, FreeSerif, serif; font-size: 15px; font-weight: bold; line-height: 1.5; position: relative; text-align: -webkit-auto; width: 568px;">
<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span class="Apple-style-span" style="color: red;">Files required :</span></b><br /><br />1. ajax.js<br />2. search.jsp<br />3. web.xml<br />4. struts-config.xml<br />5. SearchForm.java<br />6. SearchAction.java<br /><br /><b><span class="Apple-style-span" style="color: red;">Code for running the program :</span></b><br /><b><span class="Apple-style-span" style="color: red;"><br /></span></b><br /><b><span class="Apple-style-span" style="color: red;">1. ajax.js</span></b><br /><b><span class="Apple-style-span" style="color: red;"><br /></span></b><br /><br /><div style="color: blue;">
var request;</div>
<div style="color: blue;">
<br /></div>
<div style="color: blue;">
function createObject() {</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (window.XMLHttpRequest) { // Mozilla, Safari, ...</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>//alert("other than IE");</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>request = new XMLHttpRequest();</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else if (window.ActiveXObject) { // IE</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>//alert("IE only");</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>request = new ActiveXObject("Microsoft.XMLHTTP");</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="color: blue;">
}</div>
<div style="color: blue;">
function search() {</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>createObject();</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>var name=window.document.getElementById("n").value;</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>var url="search.do?name="+name;</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>request.open('GET',url,true);</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>request.send(url);</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>request.onreadystatechange= callback();</div>
<div style="color: blue;">
}</div>
<div style="color: blue;">
function callback() {</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (request.readyState == 4) {</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>displayInfo(request.responseText);<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div style="color: blue;">
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="color: blue;">
}</div>
<div style="color: blue;">
function displayInfo(str) {<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="color: blue;">
/*This function is only for testing, not working*/<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="color: blue;">
}</div>
<div style="color: blue;">
<br /></div>
<b><span class="Apple-style-span" style="color: red;">2. search.jsp</span></b><br /><b><span class="Apple-style-span" style="color: red;"><br /></span></b><br /><br /><span class="Apple-style-span" style="color: blue;"><%@ page language="java" contentType="text/html; charset=ISO-8859-1"</span><br /><span class="Apple-style-span" style="color: blue;"> pageEncoding="ISO-8859-1"%></span><br /><span class="Apple-style-span" style="color: blue;"><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"></span><br /><span class="Apple-style-span" style="color: blue;"><%@ page import="java.util.*" %></span><br /><span class="Apple-style-span" style="color: blue;"><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %></span><br /><span class="Apple-style-span" style="color: blue;"><html></span><br /><span class="Apple-style-span" style="color: blue;"><head></span><br /><span class="Apple-style-span" style="color: blue;"><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></span><br /><span class="Apple-style-span" style="color: blue;"><title>Search Page</title></span><br /><span class="Apple-style-span" style="color: blue;"><script type="text/javascript" src="ajax.js"></span><br /><span class="Apple-style-span" style="color: blue;"></script></span><br /><span class="Apple-style-span" style="color: blue;"></head></span><br /><span class="Apple-style-span" style="color: blue;"><body></span><br /><span class="Apple-style-span" style="color: blue;"><table></span><br /><span class="Apple-style-span" style="color: blue;"><form action="search.do"></span><br /><span class="Apple-style-span" style="color: blue;"><tr></span><br /><span class="Apple-style-span" style="color: blue;"><td>Enter name Here : </td></span><br /><span class="Apple-style-span" style="color: blue;"><td><input id="n" type="test" name="name" onkeyup="search()"/></td></span><br /><span class="Apple-style-span" style="color: blue;"></tr></span><br /><span class="Apple-style-span" style="color: blue;"><div id="results"></div></span><br /><span class="Apple-style-span" style="color: blue;"></form></span><br /><span class="Apple-style-span" style="color: blue;"></table></span><br /><span class="Apple-style-span" style="color: blue;"></body></span><br /><span class="Apple-style-span" style="color: blue;"></html></span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><b><span class="Apple-style-span" style="color: red;">3. web.xml</span></b><br /><b><span class="Apple-style-span" style="color: red;"><br /></span></b><br /><br /><span class="Apple-style-span" style="color: blue;"><?xml version="1.0" encoding="UTF-8"?></span><br /><span class="Apple-style-span" style="color: blue;"><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"></span><br /><span class="Apple-style-span" style="color: blue;"> <display-name /></span><br /><span class="Apple-style-span" style="color: blue;"> <servlet></span><br /><span class="Apple-style-span" style="color: blue;"> <servlet-name>action</servlet-name></span><br /><span class="Apple-style-span" style="color: blue;"> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class></span><br /><span class="Apple-style-span" style="color: blue;"> <init-param></span><br /><span class="Apple-style-span" style="color: blue;"> <param-name>config</param-name></span><br /><span class="Apple-style-span" style="color: blue;"> <param-value>/WEB-INF/struts-config.xml</param-value></span><br /><span class="Apple-style-span" style="color: blue;"> </init-param></span><br /><span class="Apple-style-span" style="color: blue;"> </servlet></span><br /><span class="Apple-style-span" style="color: blue;"> <servlet-mapping></span><br /><span class="Apple-style-span" style="color: blue;"> <servlet-name>action</servlet-name></span><br /><span class="Apple-style-span" style="color: blue;"> <url-pattern>*.do</url-pattern></span><br /><span class="Apple-style-span" style="color: blue;"> </servlet-mapping></span><br /><span class="Apple-style-span" style="color: blue;"> <welcome-file-list></span><br /><span class="Apple-style-span" style="color: blue;"> <welcome-file>search.jsp</welcome-file></span><br /><span class="Apple-style-span" style="color: blue;"> </welcome-file-list></span><br /><span class="Apple-style-span" style="color: blue;"> </span><br /><span class="Apple-style-span" style="color: blue;"></web-app></span><br /><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><b><span class="Apple-style-span" style="color: red;">4. struts-config.xml</span></b><br /><b><span class="Apple-style-span" style="color: red;"><br /></span></b><br /><br /><span class="Apple-style-span" style="color: blue;"><?xml version="1.0" encoding="UTF-8"?></span><br /><span class="Apple-style-span" style="color: blue;"><!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"></span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;"><struts-config></span><br /><span class="Apple-style-span" style="color: blue;"><form-beans></span><br /><span class="Apple-style-span" style="color: blue;"><form-bean name="searchForm" type="com.search.SerachForm"></form-bean></span><br /><span class="Apple-style-span" style="color: blue;"></form-beans></span><br /><span class="Apple-style-span" style="color: blue;"> <action-mappings></span><br /><span class="Apple-style-span" style="color: blue;"> <action path="/search" name="searchForm" type="com.search.SearchAction"></span><br /><span class="Apple-style-span" style="color: blue;"> <forward name="success" path="/search.jsp"></forward></span><br /><span class="Apple-style-span" style="color: blue;"> </action></span><br /><span class="Apple-style-span" style="color: blue;"> </action-mappings></span><br /><span class="Apple-style-span" style="color: blue;"></struts-config></span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><b><span class="Apple-style-span" style="color: red;">5. SearchForm.java</span></b><br /><b><span class="Apple-style-span" style="color: red;"><br /></span></b><br /><br /><span class="Apple-style-span" style="color: blue;">package com.search;</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">import org.apache.struts.action.ActionForm;</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">public class SerachForm extends ActionForm {</span><br /><span class="Apple-style-span" style="color: blue;">private String name;</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">public String getName() {</span><br /><span class="Apple-style-span" style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return name;</span><br /><span class="Apple-style-span" style="color: blue;">}</span><br /><span class="Apple-style-span" style="color: blue;">public void setName(String name) {</span><br /><span class="Apple-style-span" style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>this.name = name;</span><br /><span class="Apple-style-span" style="color: blue;">}</span><br /><span class="Apple-style-span" style="color: blue;">}</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><b><span class="Apple-style-span" style="color: red;">6. SearchAction.java</span></b><br /><b><span class="Apple-style-span" style="color: red;"><br /></span></b><br /><br /><span class="Apple-style-span" style="color: blue;">package com.search;</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">import javax.servlet.http.HttpServletRequest;</span><br /><span class="Apple-style-span" style="color: blue;">import javax.servlet.http.HttpServletResponse;</span><br /><span class="Apple-style-span" style="color: blue;">import org.apache.struts.action.Action;</span><br /><span class="Apple-style-span" style="color: blue;">import org.apache.struts.action.ActionForm;</span><br /><span class="Apple-style-span" style="color: blue;">import org.apache.struts.action.ActionForward;</span><br /><span class="Apple-style-span" style="color: blue;">import org.apache.struts.action.ActionMapping;</span><br /><span class="Apple-style-span" style="color: blue;"><br /></span><br /><span class="Apple-style-span" style="color: blue;">public class SearchAction extends Action{</span><br /><span class="Apple-style-span" style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>/*</span><br /><span class="Apple-style-span" style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * author : Chandrasekhara Kota</span><br /><span class="Apple-style-span" style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * Date : 03-Dec-2011</span><br /><span class="Apple-style-span" style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * Email : chandunaidu.kota@gmail.com</span><br /><span class="Apple-style-span" style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span> * */</span><br /><span class="Apple-tab-span" style="white-space: pre;"><span class="Apple-style-span" style="color: blue;"> </span></span><br /><span class="Apple-style-span" style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>public ActionForward execute(ActionMapping am, ActionForm af, HttpServletRequest req, HttpServletResponse res)throws Exception</span><br /><span class="Apple-style-span" style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br /><span class="Apple-style-span" style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("---------------inside the action------------------"+req.getParameter("name"));<span class="Apple-tab-span" style="white-space: pre;"> </span></span><br /><span class="Apple-tab-span" style="white-space: pre;"><span class="Apple-style-span" style="color: blue;"> </span></span><br /><span class="Apple-style-span" style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>return am.findForward("success");</span><br /><span class="Apple-style-span" style="color: blue;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br /><span class="Apple-style-span" style="color: blue;">}</span></div>
</div>
</div>Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-21485981175750531022012-01-23T16:28:00.000+05:302012-01-23T16:28:21.233+05:30static variable<div dir="ltr" style="text-align: left;" trbidi="on">
/*<br />
static most powerful and beautiful concept in java .if use static, jvm will load at the time of class load.<br />
if we use static for a variable it treated as class level variable for every new object will not create new variable existing only used.<br />
*/<br />
<br />
public class Static_Variable<br />
{<br />
static String collegename="ghandi college";<br />
public void method1()<br />
{<br />
//incomplete<br />
}<br />
}</div>Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-88689535204490800502012-01-23T16:14:00.000+05:302012-01-23T16:14:02.390+05:30static NOT applicable with modifiers<div dir="ltr" style="text-align: left;" trbidi="on">
/*<br />
RULE: static keyword not applicable with the<br />
1.final<br />
2. abstract<br />
and class<br />
<br />
*/</div>Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-55889732303048951382012-01-23T16:05:00.000+05:302012-01-23T16:05:22.358+05:30static applicable<div dir="ltr" style="text-align: left;" trbidi="on">
/*<br />
RULE: static keyword only applicable for variables , methods and block but not for classes<br />
*/<br />
<br />
public class Static_Demo<br />
{<br />
static int x=10;<br />
static<br />
{<br />
System.out.println(x);<br />
}<br />
public static void main(String arg[])<br />
{<br />
System.out.println("static main method")<br />
}<br />
}</div>Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.comtag:blogger.com,1999:blog-6451424366926072938.post-34680852544300125222012-01-23T15:57:00.000+05:302012-01-23T15:57:26.976+05:30public class<div dir="ltr" style="text-align: left;" trbidi="on">
/*<br />
RULE: if we declared a class as public, we can access that class from any where<br />
*/<br />
<br />
public class Public_Class<br />
{<br />
<br />
}</div>Java Ruleshttp://www.blogger.com/profile/09618135927371765100noreply@blogger.com