I have a ajax call that sends a value to the Servlet and Servlet creates a html file then returning the absolute path of the html file that has been created.
In response from the server is
"C:\Users\Ker\Documents\NETBEANS PROJECT\Titanium\build\web\default\result.html"
and in the ajax
$(function() {
$("#BTNRUN").click(function() {
var html = $("#HTML").val();
var body1 =html.replace('%','^');
var body2=body1.replace('&','|');
var css = $("#CSS").val();
var js = $("#JS").val();
var dataString = 'RUN=1&BODY=' + body2
+ '&CSS=' + css + '&JS=' + js;
$.ajax({
type: "POST",
url: "TitaniumServlet",
data: dataString,
success: function(data) {
window.open(data);
}
});
return false;
});
});
it opens a new browser but i alway go to about:blank page. is there something wrong with the adress?
edit:
try {
main_path is the context path of the project
File file = new File(main_path + "\\result.html");
if (file.createNewFile()) {
System.out.println("File is created!");
} else {
System.out.println("File already exists.");
file.delete();
file.createNewFile();
}
writer = new PrintWriter(new FileOutputStream(file, false));
writer.write(html codes here);
return file.getAbsolutePath();
} catch (FileNotFoundException ex) {
Logger.getLogger(ProcessRun.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(ProcessRun.class.getName()).log(Level.SEVERE, null, ex);
}