473,224 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

Problem with Exporting Data to Word

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,men ubar=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

Jul 24 '06 #1
2 2817
function showRTF() {
var newWin = window.open("",
"newWin","width=900,height=800%,scrollbars=yes,men ubar=yes,resizable=yes,too
lbar=yes,location=no");
window.document.formShowRTF.target="newWin";
window.document.formShowRTF.submit();
}
You might want to change that in window.open("about:blank" ...). Though
as I recently learend, Opera does handle this correctly, firefox and
internet explorer will not clear the document.

Other than that the target seems to be static, so you might want to put
that in the HTML.
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.
The window.open("" ...) _might_ cause a refresh with a GET.
>
I have also tried opening different windows for every request.
The problem with this approach is that the first window hangs or
becomes blank.
Have you used different window names?

Well, it is rather strange, but it looks like what you did should work.
I would atleast try opening with "about:blank". You might also want to
implement a small delay between the submit and the opening of the window
(using "window.setTimeout('window.document.formShowRTF.su bmit();',
20)"). If possible, keep a reference to the window, so you don't need to
open it twice:

var docWin;

function showRTF() {
if (!docWin) {
docWin = window.open("about:blank",
"newWin", .. parameters... );
} else {
docWin.focus();
}
window.document.formShowRTF.target="newWin";
window.setTimeout('window.document.formShowRTF.sub mit();', 20);
}

Something like that.

Hope it helps,
Vincent
Jul 24 '06 #2
Mux
Hi,

Thanks for replying to my query..

Most of options have been tried like giving different window names.
the about_blank tip is what i would have to try though...

also the delay bit, i have given that a shot...howvever that aint a
very good approach as it depends on the ntw speed.
The desired effect may not always be possible.

I will give this one more try, and let u knw.

Thanks!
Mukta

Jul 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jayjay | last post by:
Is it possible to export a report to word and have it include the graphics that are in the report? I'd like to take some of our reports and export them to word so we can email those to the...
0
by: Otis Hunter | last post by:
I have been fighting with this for days and your expert help is needed! Below is the code I am executing which results with "Object doesn't support this property or method". The error is occuring...
8
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
5
by: mik18 | last post by:
I'm having trouble with exporting reports to Word in the rtf format and I'm hoping someone has a solution. The reports are losing their formats. Not all the formating is lost but some is and of...
1
by: Thankful Idiot via AccessMonster.com | last post by:
I was wondering if anyone knew anything about exporting data to ms word documents. I have a program that can gather data such as customer addresses, and would like to move it to a ms word document...
1
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream...
15
by: =?ISO-8859-1?Q?J=F8rn?= Dahl-Stamnes | last post by:
Hello folks, I need some help/advice FAST. I have problems with addslashes on my web-servers. After uploading a file, I read the uploaded file, use addslashes on the read data and then insert...
0
by: Dan | last post by:
Hi, i have some problem with exporting data from sql server to some formats. Excel and Word are not a problem, but .txt and .csv do not work properly: - with .txt, the data are shown (correctly)...
1
by: Mientje | last post by:
I've made an Access 2007 database to store information about the lessonplans I have to make every schoolyear. I want to export the data form the table "Lesvoorbereiding" (Lessonplans in English) to...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.