Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with JSP

Status
Not open for further replies.

dinamdar

Programmer
Jun 3, 2004
8
US
I have a jsp page. The code is as follows. It is not opening word template. The code looks ok but when I run it from the application it doesn't open the word. I have enabled ActiveX control options in Internet explore. Can anyone help me with this? Thanks.

The code is as follows.

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function printClicked () {
document.mainForm.textfield.focus();
document.mainForm.textfield.select();
Copied = document.mainForm.textfield.createTextRange();
Copied.execCommand("Copy");
var objWord = new ActiveXObject("Word.Application");
if (objWord != null)
{
objWord.visible = true;
objWord.Documents.Open(" objWord.Selection.Paste();
}
}
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<table width="760" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;
</td>
<td>
<input type="text" name="textfield">
</td>
</tr>
<tr>
<td>
<input type="button" name="Button2" value="Print" onClick="printclicked()">
</td>
<td>&nbsp;</td>
</tr>
</table>
</form>

</body>
</html>
 
Well, I see two things wrong so far. In your button you have printclicked(), but your function is printClicked(). JavaScript is case sensitive. Also, your form name is "form1", but you are referring to a form named "mainForm" in your code.

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Thanks for the reply. After I corrected your point outs it is still not opening the Word Application. It works fine upto copy command. any idea?
 
When I applied Adam's changes to your original code, it worked fine. The only other change I made was the path to the Word document to open. I changed this:

Code:
objWord.Documents.Open("[URL unfurl="true"]http://Myserver/App/LP.dot");[/URL]

to this:

Code:
objWord.Documents.Open("file:///C:/test.doc");

And it worked fine.

Do you actually have Word on your system? Do you have your security settings to allow ActiveX controls to run (or at least prompt you to run them)?

Hope this helps,
Dan
 
No luck. Yes I have word installed on local and Tomcat server. I have security settings to allow ActiveX controls to run. When I run from localhost it is opening Word but not from the the application. Now I get error saying word cannot open the existing "

after double quotes some square box appears

Thanks for reply
 
I apologize for asking this simple question, but is your document in the right place on the server? If you type the URL of the document you want to open in the address bar of your browser, you get prompted to download it, right?

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Yes I have the word template which is suppose to open.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top