Thursday, August 27, 2009

File Upload Struts2

This is a sample program to upload a file and save to databse using hibernate contains a file field and a submit button
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:form action="addDocument" enctype="multipart/form-data" method="POST">
<td><s:file label="File" name="data"></s:file></td>
<s:submit type="submit" theme="simple" value="Upload" />
package in.codeglobe.fileupload.action;
public class DocumentAction extends ActionSupport {
private File data;
private String dataContentType;
private String dataFileName;
private Document document = new Document();

public Document getDocument() {
return document;

public void setDocument(Document document) {
this.document = document;

public File getData() {
return data;

public void setData(File data) { = data;

public String getDataContentType() {
return dataContentType;

public void setDataContentType(String dataContentType) {
this.dataContentType = dataContentType;

public String getDataFileName() {
return dataFileName;

public void setDataFileName(String dataFileName) {
this.dataFileName = dataFileName;

public String add() {
String result = "view";
try {
FileInputStream fis;
byte[] content = null;
try {
fis = new FileInputStream(data);
content = new byte[fis.available()];;
} catch (Exception e) {
throw e;
u have to write the code to save in to the database
} catch (Exception e) {
return result;
The addDocument action in the fileupload.jsp invokes the add method in the DocumentAction class
this method reads the datafrom the uploaded file and store it to the byte array in the
document class.

this is the action mapping for the upload file after successful upload page is redirected to success.jsp
<action name="*Document" method="{1}"
<result name="view">/success.jsp</result>
package in.codeglobe.fileupload.entity;
public class Document {

private Long documentId;
private String fileName;
private String contentType;
private byte[] data;

public Document() {


public String getFileName() {
return fileName;

public void setFileName(String fileName) {
this.fileName = fileName;

public String getContentType() {
return contentType;

public void setContentType(String contentType) {
this.contentType = contentType;

public byte[] getData() {
return data;

public void setData(byte[] data) { = data;

public Long getDocumentId() {
return documentId;

public void setDocumentId(Long documentId) {
this.documentId = documentId;

File with file name ${dataFileName} is successfully uploaded to database
File type: ${dataContentType}

This is the hibernate configuration
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"


<class name="in.codeglobe.fileupload.entity.Document"
<id name="documentId" column="documentId">
<generator class="native" />
<property name="data">
<column name="data" sql-type="MEDIUMBLOB"></column>
<property name="fileName" />
<property name="contentType" />

cheapest web development hosting solutions cochin kerala

Running ASP.NET Applications in Debian and Ubuntu

Mono is an open-source project providing the necessary software to develop and run .NET client and server applications on Linux, Solaris, Mac OS X, Windows, and Unix. Monodevelop is probably the best IDE for developing .NET applications on Linux. In order to install and use it for development, you will also need the Mono .NET runtime environment installed.

Mono has a fully functional implementation of ASP.NET. This includes full support for ASP.NET Web Forms and Web Services. This essentially means that more or less any ASP.NET application that you have developed using with the .NET Framework will work with MonoASP.NET with Mono you have two options as regards which web server to host your ASP.NET applications that is XSP and Apache.
XSP is a “light-weight web server” capable of hosting and serving ASP.NET applications. It is written using C#, making extensive use of the classes in the System.Web namespace.XSP web server runs on both the Mono runtime and also on the .NET runtime.
Now we are going to take a look how to install XPS and mono for ASP.NET applications and testing this setupnstall mono in Debian
If you want to install mono in your debian system you need to run the following command
#apt-get install mono mono-gmcs mono-gac mono-utils monodevelop monodoc-browser monodevelop-nunit monodevelop-versioncontrol
You can can see in this screen which will install all the required packages

Install mono in Ubuntu
If you want to install mono in your Debian system you need to run the following command
sudo apt-get install mono mono-gmcs mono-gac mono-utils monodevelop monodoc-browser monodevelop-nunit monodevelop-versioncontrol
Install XSP Web server in Debian
If you want to install ASP.NET2.0 version use the following command
#apt-get install mono-xsp2 mono-xsp2-base asp.net2-examples
If you want to install ASP.NET1.0 version use the following command
#apt-get install mono-xsp mono-xsp-base
This will install all the required development environment and sample applications
Install XSP Web server in Ubuntu
If you want to install ASP.NET2.0 version use the following command
sudo apt-get install mono-xsp2 mono-xsp2-base asp.net2-examples
If you want to install ASP.NET1.0 version use the following command
sudo apt-get install mono-xsp mono-xsp-base
This will install all the required development environment and sample applications for ASP.NET
Test ASP.NET Applications
We have already installed sample applications
If you want to run ASP.NET 2.0 application you need to go to /usr/share/asp.net2-demos/ run the following command
This will start the XSP with ASP.Net 2.0 application
Listening on port: 8080 (non-secure)
Listening on address:
Root directory: /usr/share/asp.net2-demos
Hit Return to stop the server.
Now you need to point your web browser to http://localhost:8080/
If you want to run ASP.NET 1.0 application you need to go to /usr/share/ run the following command
This will start the XSP with ASP.Net 1.0 application
Listening on port: 8080 (non-secure)
Listening on address:
Root directory: /usr/share/
Hit Return to stop the server.
Now you need to point your web browser to http://localhost:8080/
Possible errors
If you get the following error when you point http://localhost:8080/
Error Message: HTTP 404. File not found /usr/share/asp.net2-demos/index2.aspx
You need to copy the index.aspx to index2.aspx
For Debian Users
#cp /usr/share/asp.net2-demos/index.aspx /usr/share/asp.net2-demos/index2.aspx
For Ubuntu Users
sudo cp /usr/share/asp.net2-demos/index.aspx /usr/share/asp.net2-demos/index2.aspx

.net application developers cochin kerala

web IT solutions cochin Kerala

Get Running Process C#

using System.Diagnostics;
ProcessThreadCollection threadlist = theProcess.Threads;

foreach(ProcessThread theThread in threadlist){
Console.WriteLine("Thread ID:{0} Priority: {1} Started: {2}", theThread.Id, theThread.PriorityLevel, theThread.StartTime);

Tuesday, August 25, 2009

PixelShots a Mobile Photography blog

An ultimate place for cellphone photography, Digital photography using various MP cell phone cameras

kerala webdesigns cochin

Send Mail Using JAVA MAIL API

The JavaMail API is a set of abstract APIs that model a mail system. The API provides a platform independent and protocol independent framework to build Java technology based email client applications. The JavaMail API provides facilities for reading and sending email. Service providers implement particular protocols. Several service providers are included with the JavaMail API package; others are available separately. The JavaMail API is implemented as a Java optional package that can be used on JDK 1.4 and later on any operating system. The JavaMail API is also a required part of the Java Platform, Enterprise Edition (Java EE).
You can download Java Mail API from

An Example program for sending mail using JAVA Mail
Before run the example code please goes through steps given below

1. download java mail API. and add to Classpath
2. Create one Gmail Account ( in this example we use google mail server as server)
3. edit the code "USERNAME = new gmail id" and PASSWORD = "password of new gmail id";
4. edit formAddress and to address.

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendMail {

public static final String MAIL_SERVER = "";
public static final String USERNAME = "";
public static final String PASSWORD = "password";

public static void main(String[] args) {
try {
fromAddress = "";
String toAddress = "";
String subject = "This is a test Message";
String message = "Hello Hows u?";

Properties properties = System.getProperties();
properties.put("", MAIL_SERVER);
properties.put("mail.smtps.auth", "true");

Session session = Session.getInstance(properties);
MimeMessage msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(fromAddress));
msg.addRecipients(Message.RecipientType.TO, toAddress);

Transport tr = session.getTransport("smtps");
tr.sendMessage(msg, msg.getAllRecipients());
} catch (AddressException ex) {
} catch (MessagingException ex) {

webdevelopers webhosting application development-IT solutions Cochin Kerala

Monday, August 24, 2009

Snake game for U in turbo c

# include <stdio.h>
# include <graphics.h>
# include <stdlib.h>
# include <dos.h>
# include <conio.h>
int gdriver=DETECT,gmode,x1=0,y1=0,x2,y2,k=0,c,a,i=0;
int bufx[150],bufy[150],dist=7,delayspeed=100,d;
int rndx,rndy,tail=2,size,dash=0;
int life=5;
int choice;
void randomnumber(void);
void move(int a);
void statusbar(void);
void main()
// registerfarbgidriver(EGAVGA_driver_far);
printf("Devlopped By IDEAL BERG");
printf("Enter the speed:: \n<1> for slow <2> for slower <3> for slowest\n<4> for normal\n<5> for fast <6> for faster <7> for fastest");
case 1: delayspeed=250;break;
case 2: delayspeed=200;break;
case 3: delayspeed=160;break;
case 4: delayspeed=90;break;
case 5: delayspeed=60;break;
case 6: delayspeed=40;break;
case 7: delayspeed=20;break;
if (c=='\115') a=1;
if (c=='\113') a=2;
if (c=='\120') a=3;
if (c=='\110') a=4;
void move(int a)
void checkcollision(int x1,int y1);
void checkcapture(int x1,int y1);
if (!dash)
if(i>=size) // Style start
if(a==1) x1=x1+dist;
if(a==2) x1=x1-dist;
if(a==3) y1=y1+dist;
if(a==4) y1=y1-dist;

void checkcollision(int x1,int y1)
int i;
for(i=1;i<=size;i++) if((bufx[i]==x1)&&(bufy[i]==y1)) dash=1; if((x1<0)||(x1>=400)||(y1<0)||(y1>400)) dash=1;
if(--life<0) exit(0); sound(700); delay(300); nosound(); if(size>25) life++;size=tail;

void checkcapture(int x1,int y1)
int i;
void statusbar()
char s[10];
printf("Life: %d size: %d",life,size);
printf("Down: ");
printf("RIGHT :");
printf("\tLEFT :");
void randomnumber()
int i,j;

Kerala IT companies - webdevelopment webhosting application development Cochin

Monday, August 17, 2009

"Setup did not find any hard disk drives" during Windows XP Installation on Dell Laptops

Are you experience trouble installing Windows XP in your Dell Laptop?

Before you install XP, you must first configure a setting in BIOS else XP CD will not detect your hard disk


Onboard Devices -> Flash Cache Module -> Set Off
Onboard Devices -> SATA Operation -> Set ATA

Ok, you can now proceed with installing Windows XP

Sunday, August 2, 2009

Rediif Local Ads

Rediff LocalAds is a service that provides you to register your add to rediff's advertising program subject to your compliance with Terms and Conditions. Now rediff offers these services totally free including the communication(Phone) between the customer and advertiser. Customers can search products that they want to buy and rediff lists all ads relating to that product. They can also call to the advitiser(1 minute) totally free.

Link to add your local ad

Google SMS Channel

This is another product from Google Labs. You can create your own channel(s) to receive regular alerts over SMS on specific topics that interest you. You can also invite others to subscribe to your channel(s). You can use your channel(s) as a discussion group as well, allowing other people to post messages.
The main advantage is that you can use this channel to alert your readers when a new post is published in your blog. You need not take any effort for this. Google automatically do this. Only thing is that at the time of creation you need to provide your blog's address. You can also use this to provide alert from your google groups, Google news or from a RSS feed as shown in the figure. Also you(channel owner) can post messages manually. You can click here to start your own SMS channel.

Link for SMS subscribtion to codeglobe

Saturday, August 1, 2009

think beyond wml.

HAWHAW is a toolkit that helps webmasters to make their website mobile, i.e. accessible by a wide range of mobile devices and standard browsers.

What stands the name 'HAWHAW' for?

HTML And WML Hybrid Adapted Webserver.

for more details

Type in Malayalam in any text box on any web-site of your choice

Transliteration bookmarklet is a small piece of code that you store in your browser. Once stored, you can type in Malayalam in any text box on any web-site of your choice. It works on Google web-sites as well as other web-sites.

Click here to get the transliteration bookmarkle

NB : You should install malayalam font to use this option.

For other languages, use the appropriate link: Arabic Bengali Gujarati Hindi Kannada Malayalam Marathi Nepali Tamil Telugu

Inserting images in Gmail

Well friends, it's about time. You no longer have to use workarounds to put images into your messages or attach images when you really want to inline them. Just turn on "Inserting images" from the Labs tab under Settings, and you'll see a new toolbar icon like this:

Make sure you're in rich formatting mode, or it won't show up. Click the little image icon, and you can insert images in two ways: by uploading image files from your computer or providing image URLs.

Keep in mind that Gmail doesn't show URL-based images in messages by default to protect you from spammers, so if you're sending mail to other Gmail users, they'll still have to click "Display images below" or "Always display images from ..." to see images you embed.


Related Posts with Thumbnails