0

I am trying to make a form using html and JSP, get the data and save them in an XML file. I use also Tomcat 1.6 as server. For generating the XML I am using the XStream library.
I have a Customer.java class with get and set methods for a message and an email. Then I have a GenerateXml.java file which creates a Customer object, get the data and add them in an XML file:

Customer customer = new Customer();
customer.getMessage();
customer.getEmail();
XStream xs = new XStream();
try {
FileOutputStream fs = new
FileOutputStream("C:\\customers.txt");
xs.toXML(customer, fs);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}

Then I have a createForm.html file which creates a form and call the SaveData.jsp, which is:

/*SaveData.jsp*/
<jsp:directive.page import="xmlParsing.Customer"/>
<jsp:useBean id="customer" class="xmlParsing.Customer" scope="session"/>
<jsp:setProperty name="customer" property="*"/>
<jsp:directive.page import="xmlParsing.GenerateXml"/>
<jsp:useBean id="xml" class="xmlParsing.GenerateXml" scope="session"/>
<jsp:setProperty name="xml" property="*"/>
<html>
<body>
You entered
Message: <%= customer.getMessage() %>
Email: <%= customer.getEmail() %>
<%= xml.setXml() %>
</body> </html>

The problem is that when I am trying to run the program I get an error :
"org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 15 in the jsp file: /SaveData.jsp The method print(boolean) in the type JspWriter is not applicable for the arguments (void) .... Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439) org.apache.jasper.compiler.Compiler.compile(Compiler.java:349) org.apache.jasper.compiler.Compiler.compile(Compiler.java:327) org.apache.jasper.compiler.Compiler.compile(Compiler.java:314) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) "

Does anyone know what is wrong with it?

Thanks

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by novellino
0

Ok I fixed it!!
It should be <% xml.setXml(); %> instead of <%= xml.setXml() %>.

Thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.