Skip to main content

Posts

Uploading a binary file to RESTful web service in java using Jersey

Hi, Recently I had a situation where I was supposed to upload a binary file to a server side RESTful web service created in Jersey. I faced a lot of trouble in doing so because always one or the other part of the hood was not working properly. The following post gives a step by step process as how to create a RESTful service that accepts uploaded binary files. Pre-requisites: 1. A running RESTful service based on Jersey. 2. An HTML page with file upload component. 3. Tomcat 7 as web server. 4. Eclipse indigo. Note: Let us suppose that tomcat is running on same machine on which the HTML client is present. So we will be using the base domain URL as ' http://localhost:8080/ '. If your service and client are located on different instances of tomcat then replace the localhost part of the URL with the IP address of the machine on which the REST service is running. Step 1 (Eclipse setup): a. Create a 'Dynamic Web Project' in eclipse indigo. Let us say that thi...

Parsing an XML document using SAX Parser in Java

This is again a "getting started tutorial" of how to start using XML parsing concepts in java. For further details of using XML parsing please refer tutorials at : http://docs.oracle.com/javase/tutorial/jaxp/sax/index.html . The program presented here is a simple demonstration of how to parse an XML document using SAX-XML parser for java. For demonstration purpose a sample .xml file is also included. temp.xml : <?xml version="1.0"?> <company>     <staff department="information security">         <firstname>FIRST NAME-1</firstname>         <lastname>LAST NAME-1</lastname>         <nickname>STUDENT-1</nickname>         <salary>100000</salary>     </staff>     <staff>         <firstname>FIRST NAME-2...

Creating a JAX-WS Web Service and Client using Eclipse Indigo

Creating a JAX-WS Web Service and corresponding client is a very trivial task. However I faced various problems while doing the same mainly while creating a client for the web service. This was mainly because the contents I found on the Internet were in a distributed manner. So I thought of creating a tutorial which binds all the concepts at one place. So this tutorial does not teaches indepth concepts of web services. Instead it guides as how to create a Web Service and a seperate client. Software Requirements: 1. Eclipse Indigo. Note: To download Eclipse Indigo follow the link http://www.eclipse.org/downloads/. Then select 'Eclipse IDE for Java EE Developers'. Process: We will proceed with the creation of web service and client in following two steps: 1. Creating Web Service 2. Creating client to consume web service. 1. Creating Web Service: Creating of a JAX-WS web service is not a very tough task. We simply create a class(normal Java class) and define certai...

Hibernate 3 with Eclipse helios (Eclipse 3.6)

There are many blogs and tutorials on this topic. However I faced many problems while integrating Hibernate 3.0 with Eclipse Helios. Most of the problems were related to the version mismatch among the components used to create a Hibernate project on Eclipse Helios. Software Requirements: 1.        Eclipse Helios (This tutorial could work with other versions of Eclipse but it is specially designed for Helios version.) 2.        hibernate-distribution-3.6.5.Final-dist bundle (zip file). Download the bundle from http://www.hibernate.org/downloads . It will be around 59.2 MB jar file. 3.        MySql connector for Eclipse “mysql-connector-java-5.0.8 (zip)”. 4.        slf4j-1.6.1 bundle (zip form) 5.        apache-log4j-1.2.16 bundle(zip form) 6.        commons-logging-1.1.1.jar Pre-Requisites: 1.   ...