M
Mux
I am facing the following problem while exporting data to Word.
The current implementation is as described below:
I have a JSP file which has a link that enables you to export the data
to
Word.
Clicking on the link invokes a javascript function:
function showRTF() {
var newWin = window.open("",
"newWin","width=900,height=800%,scrollbars=yes,menubar=yes,resizable=yes,too
lbar=yes,location=no");
window.document.formShowRTF.target="newWin";
window.document.formShowRTF.submit();
}
and submits the form:
<form name="formShowRTF" method="POST"
action="http://<IP>/SampleApplication/servlet/mypackage.ExportServlet">
<input type="hidden" name="RTFData" value="<%=strTemp%>" >
Now submiting the form (POST operation)....invokes the Servlet which
performs the export of the data.
The data is passed as a hidden form parameter.
The ExportServlet immplementation is as follows:
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException
{
response.setContentType("application/msword");
ServletOutputStream os =
response.getOutputStream();
String strTemp = request.getParameter("RTFData");
if (strTemp==null)
{
strTemp = "No Data";
}
os.write(strTemp.getBytes());
}
Now let me explain the problem area:
Exporting the data to word for the very first time, opens a popup
window
having an inline word document.
Data gets exported to the word document within the popup window.
Now, if i keep the popup window containing the data open, and i again
request an export operation,
i.e. i again click on the export to word link, this time the pop up
window
is not refreshed with the new data requested!!
Whats happening surprisingly is, instead of calling the doPost() method
of
the Servlet, the doGet() method
is invoked the second time when you request an export operation, with
the
popup window open.
This is quite strange!!
I have also tried opening different windows for every request.
The problem with this approach is that the first window hangs or
becomes
blank.
The first window displays the data, but its the earlier data and not
the new
requested data.
The reason i guess is again same:
the doGet() method is invoked the second time an export request is
made,
instead of doPost().
Also, no data is fetched in the doGet() method.
Another alternative is opening different Word docs for every request
instead
of an inline doc.
However, I would like to know if there is a way to refresh the contents
of
the inline document using JScript that is already open within a browser
window?
Regards,
Mukta
The current implementation is as described below:
I have a JSP file which has a link that enables you to export the data
to
Word.
Clicking on the link invokes a javascript function:
function showRTF() {
var newWin = window.open("",
"newWin","width=900,height=800%,scrollbars=yes,menubar=yes,resizable=yes,too
lbar=yes,location=no");
window.document.formShowRTF.target="newWin";
window.document.formShowRTF.submit();
}
and submits the form:
<form name="formShowRTF" method="POST"
action="http://<IP>/SampleApplication/servlet/mypackage.ExportServlet">
<input type="hidden" name="RTFData" value="<%=strTemp%>" >
Now submiting the form (POST operation)....invokes the Servlet which
performs the export of the data.
The data is passed as a hidden form parameter.
The ExportServlet immplementation is as follows:
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException
{
response.setContentType("application/msword");
ServletOutputStream os =
response.getOutputStream();
String strTemp = request.getParameter("RTFData");
if (strTemp==null)
{
strTemp = "No Data";
}
os.write(strTemp.getBytes());
}
Now let me explain the problem area:
Exporting the data to word for the very first time, opens a popup
window
having an inline word document.
Data gets exported to the word document within the popup window.
Now, if i keep the popup window containing the data open, and i again
request an export operation,
i.e. i again click on the export to word link, this time the pop up
window
is not refreshed with the new data requested!!
Whats happening surprisingly is, instead of calling the doPost() method
of
the Servlet, the doGet() method
is invoked the second time when you request an export operation, with
the
popup window open.
This is quite strange!!
I have also tried opening different windows for every request.
The problem with this approach is that the first window hangs or
becomes
blank.
The first window displays the data, but its the earlier data and not
the new
requested data.
The reason i guess is again same:
the doGet() method is invoked the second time an export request is
made,
instead of doPost().
Also, no data is fetched in the doGet() method.
Another alternative is opening different Word docs for every request
instead
of an inline doc.
However, I would like to know if there is a way to refresh the contents
of
the inline document using JScript that is already open within a browser
window?
Regards,
Mukta