Hey, I have written a program in
jsp which calls an external
java program and requests for the creation of a text file as follows
index.jsp
<%@ page import="java.io.*" %>
<jsp:useBean id="blogs3" scope="session" class="blogs.Q3" />
<html>
<head>
<title>Author Result</title>
</head>
<body>
Blog Created<br>
<%= blogs3.doit() %><br>
</body>
</html>
And the java program is as follows
Q3.java
package blogs;
import java.io.*;
public class Q3
{
public static FileOutputStream out;
public static PrintStream p;
public static DataInputStream in = new DataInputStream(System.in);
public static
String a = "myfile.html";
public static StringBuffer ab = new StringBuffer();
public static void main(String args[])
{
}
public static String doit()throws Exception
{
out=new FileOutputStream(a);
p = new PrintStream(out);
System.out.println("Write now");
ab.append("adfdfdsdfdsfdsf fsdfsfsfsfsfsfdsffdfddfsdfs dffsdfssfsdfdsfbrcd");
p.println(ab);
p.close();
return "abc";
}
}
This program above gives output as
blog created
abc
But does not create a myfile.txt file.Please Help
The Q3 programm when individually compiled using javac creates the file very well. But does not works with jsp.