Ok here is my problem. I have a Java servlet wherein it has a StringBuffer that appends my html tags and a JavaScript. My question is that is there a way wherein I can append a JavaScript in the StringBuffer using response.setContentType("text/html")? oris there another way to append a JavaScript in Java to be flushed in html?
Below is a sample script I made.
Code: Select all
StringBuffer buff = new StringBuffer();
buff.append("<p>just some text here..</p>");
buff.append("<script \"text/javascript\">callFunction();</script>");
response.setContentType("text/html");
response.getWriter().println(buff.toString());
response.getWriter().flush();
Thanks