473,386 Members | 1,764 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,386 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 2829
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.