-2

I have been working with some code that i inherited at work and added some new things to it, but now, the data won't print.

The code uses document.write and uses a .js file to help and store strings that are then printed in the JSP using document.write.

rset is a ResultSet

Here is an example:

From the JSP: testme.jsp

<td class="class" width="200" style="border-right: 1px solid<%= v_border %>;"><%= rset.getString("getMe") %> &nbsp;&nbsp;

    (<script language="javascript">document.write(disp['getMe']['<%= rset.getString("getMe").substring(0,1) %>']); </script>)
</td>

From JS file: disp.js

 disp["getMe"]=new Array()
 disp ["getMe"]["X"] = "You Printed Me!";

The code above is just like other code from the program and that code works, but i can't figure out what is different about what I wrote that would cause issues and not print when the correct conditions are met.

When the conditions are met, the display output looks like: Hi There! (You Printed Me!) in the JSP

The text in the parenthesis is meant to be a description of the values that were taken and displayed from the ResultSet.

I know scriptlets and document.write may not be best practice for this sort of thing, but i have been limited in what i can change and use in the code that was given to me.

I went back to the code today and messed around with the other sections that print properly and discovered that modifying the print values in the JS file, did NOT get reflected when displaying the data. So I think something else might be going on as well.

Any help would be really appreciated. I am new to using JavaScript to print data to a JSP.

Thank you!!

user3183843
  • 57
  • 1
  • 9
  • 1
    *:We're gonna party like it's 1995:*, love the `language` attribute and the `document.write`, it's just like the code they wrote back in the nineties. – adeneo Aug 05 '14 at 21:26
  • @adeneo hang in there man – Pointy Aug 05 '14 at 21:27
  • 2
    What's in the generated HTML at your ` – Dave Morrissey Aug 05 '14 at 21:27
  • @DaveMorrissey I went back to the code today and updated the question to be more specific, but the the result from the – user3183843 Aug 06 '14 at 21:43

2 Answers2

0

Probably a typo: you don't close the bracket of document.write, thus modify:

<script language="javascript">document.write(disp['out']['<%= print %>']; </script>))

into

<script language="javascript">document.write(disp['out']['<%= print %>']);</script>)
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
  • You are correct. I missed that when i typed the code yesterday. However, i went back to the code today and updated the question. The error that was in the code that i wrote previously was corrected but it still won't print. – user3183843 Aug 06 '14 at 21:46
0

It turns out that i had to DELETE my temporary internet files from IE.

After the delete, everything worked fine.

Thank you again for all your help!

user3183843
  • 57
  • 1
  • 9