How to read and write in file through JSP

<%@ page import="java.io.*" %>


Read write file JSP



<%
String fileName=getServletContext().getRealPath("jsp.txt");

File f=new File(fileName);

InputStream in = new FileInputStream(f);

BufferedInputStream bin = new BufferedInputStream(in);

DataInputStream din = new DataInputStream(bin);
StringBuffer sb=new StringBuffer();
while(din.available()>0)
{
sb.append(din.readLine());
}

try {
PrintWriter pw = new PrintWriter(new FileOutputStream("c:/file.txt"));// save file
pw.println(sb.toString());
pw.close();
} catch(IOException e) {
e.getMessage();
}

in.close();
bin.close();
din.close();
%>
Successfully write file



Java Servlet to Write to a temporary file

/**
* Write to a temporary file
* @author Sanjeev Kulkarni
* @since 0.5 - 18-Nov-2009 3:23:35 PM
* @version 0.1
*/

package com.ack.web.servlet;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class WriteToATemporaryFile extends HttpServlet {

public void doGet( HttpServletRequest req, HttpServletResponse res )
throws ServletException, IOException {
// get the web applications temporary directory
File tempDir = (File) getServletContext().
getAttribute( "javax.servlet.context.tempdir" );

// create a temporary file in that directory
File tempFile = File.createTempFile( getServletName(), ".tmp", tempDir );

// write to file
FileWriter fw = new FileWriter( tempFile );
try {
fw.write( "done and dusted" );
}
finally {
fw.close();
}

// tell servlet client where to look for file
res.getWriter().println( "check file: " + tempFile.getAbsolutePath() );
}

}

Happy Deepavali

Diwali or Deepaavali means an Array of Lamps i.e .Rows of diyas (Deep = Lamp, Vali =Array)

Of all the festivals celebrated in India, Diwali is by far the most glamorous and important. Enthusiastically enjoyed by people of every religion, its magical and radiant touch creates an atmosphere of joy and festivity.

As a family festival, it is celebrated 20 days after Dussehra, on the 13th day of the dark fortnight of the month of Ashwin (October / November).


It is a festival of lights symbolizing the victory of righteousness and the lifting of spiritual darkness. It celebrates the victory of good over evil - and the glory of light. This festival commemorates Lord Rama's return to his kingdom Ayodhya after completing his 14-year exile.

Homes are decorated, sweets are distributed by everyone and thousands of lamps lit to create a world of fantasy.

Deepaavali is a time for fun and revelry. Diwali is also a time for pooja and tradition. This Diwali festival, it is surmised dates back to that period when perhaps history was not written, and in its progress through centuries it lighted path of thousands to attain the ultimate good and complete ecstasy.

Deepavali is very enthusiastically celebrated for five continuous days and each day has its significance with a number of myths, legends and beliefs.

Jai Shri Laxshmidevi...

Happy Independence Day!!!

On Independence Day Here’s wising our dreams of a new tomorrow come true for us… NOW AND ALWAYS!!!

Take a stand against evil, corruption & terrorism 4 we belong to India, a nation of pride & we will thus say- "HINDU, MUSLIM, SIKH, ISAI, SAB HAI BHAI BHAI."
god bless all of us!!!

Happy Independence Day!!!

Orkut Scraps
Sanjeev Kulkarni

Bhuvan, (Sanskrit: भुवन, lit: Earth) launched by ISRO

ISRO launched the beta version of its web-based 3-D satellite imagery tool, Bhuvan, on August 12, 2009. Bhuvan will offer superior imagery of Indian locations compared to other Virtual Globe software with spatial resolutions ranging from 6 m to 55 m. Locations can be viewed from different perspectives and will allow for the measurement of distances. The Bhuvan portal is designed to run on slow Internet connections. The imagery would steer clear of all sensitive military installations in India for security concerns.

Bhuvan displays better images of India than the ones relayed by Google Earthweatherstates and districts, relevant only to the country. Bhuvan is equally capable of offering images of the globe, but the best resolution area includes India at the moment. In the Indian subcontinent, Bhuvan will be able to display a picture from ten meters away that is; a commuter moving on the road can be easily spotted.[5] along with a number of other interesting features which include information and even administrative boundaries of all

File:Bhuvanscreenshot.jpg

National Remote Sensing Agency played an important role in the creation of this product. ISRO has used data provided by satellites including Resourcesat-1, Cartosat-1 and Cartosat-2 to get the best possible imagery for India. ISRO claims that the application can provide imagery of up to 10 metres for major Indian cities compared to 200 meters provided by Google Earth.