nediam1234
asked on
Problem creating servlet as a subclass!
I just created a java class that creates an excel document.
It has a function called saveToFile which saves the excel document to a file.
Now I also want to be able to "download" the document just created, I know I could create another class (a servlet) setting the content type to "application/vnd.ms-excel" and then download the file... But! I would like to do this in a single file (not create another file for the servlet), so I thought about creating a servlet subclass. But then I don't know how I can call the subclass from the other class. Any idea how I can achieve my goal (either by servlet subclass or anything else....) ??
Am I explaining my problem well enough?
thanks
It has a function called saveToFile which saves the excel document to a file.
Now I also want to be able to "download" the document just created, I know I could create another class (a servlet) setting the content type to "application/vnd.ms-excel"
Am I explaining my problem well enough?
thanks
Subclassing will also introduce a new class. Why not just create a new Servlet class? I think that would be more maintainable.
ASKER
thanks for a quick reply,
When I save my excel sheet to a file I use something like:
ExcelSheet sheet = new ExcelSheet();
sheet.someFunctionToCreate TheDocumen t();
sheet.someAnotherFunctionT oCreateMor eOfTheDocu ment();
Then, I can call
sheet.saveToFile("myFilena me.xls");
to save the file.
It would be nice to be able to call something like this in the jsp page:
response.sendRedirect(shee t.download Servlet);
to "download" the document. Without having to pass the whole document as a parameter to another servlet (the variable "sheet" in the above sample already has the whole excel document in an variable).
are you saying that I should call something like this? :
ExcelSheet sheet = new ExcelSheet();
sheet.someFunctionToCreate TheDocumen t();
sheet.someAnotherFunctionT oCreateMor eOfTheDocu ment();
location.href= 'newServletFromANewFile?th eData=<%=s heet.getTh eWholeDocu mentAsStri ng()%>';
then my question is... isn't it a problem calling a servlet if the excel sheet is be big?
When I save my excel sheet to a file I use something like:
ExcelSheet sheet = new ExcelSheet();
sheet.someFunctionToCreate
sheet.someAnotherFunctionT
Then, I can call
sheet.saveToFile("myFilena
to save the file.
It would be nice to be able to call something like this in the jsp page:
response.sendRedirect(shee
to "download" the document. Without having to pass the whole document as a parameter to another servlet (the variable "sheet" in the above sample already has the whole excel document in an variable).
are you saying that I should call something like this? :
ExcelSheet sheet = new ExcelSheet();
sheet.someFunctionToCreate
sheet.someAnotherFunctionT
location.href= 'newServletFromANewFile?th
then my question is... isn't it a problem calling a servlet if the excel sheet is be big?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.