aspose file tools*
The moose likes JSP and the fly likes weird code idiom in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "weird code idiom in jsp" Watch "weird code idiom in jsp" New topic
Author

weird code idiom in jsp

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575


interesting.now, I come across this in one of jsp page. why would the author specify the input tag through document.write instead of directly writing it .
is there any reason to do like above?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61762
    
  67

No reason at all.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

I concur.

Everything is hard-coded it seems. The only reason one might use document.write() is to produce dynamic content
based on variables. Maybe at some point the literals were variable ?

now it could also be based on where the fragment is. If at the very end of the rendering of the table it may be
stopping someone clicking the deleteAll before everything is finished being presented.

WP
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61762
    
  67

William P O'Sullivan wrote:
The only reason one might use document.write() is to produce dynamic content
based on variables.

This may have been true in 1998. Even for such purposes document.write is a dinosaur. There are much better ways to inject dynamic content in the current millennium.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42918
    
  68
The checkbox will only be shown if JavaScript is enabled - which makes sense, because it's a JavaScript URL that wouldn't work without it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61762
    
  67

There are still better ways to do it. document.write is looked at in the JavaScript world with the same level of derision that scriptlets are in JSPs -- perhaps even more so.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Thanks every one for their valuable input. may be the intention of the author is what Ulf pointed out .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: weird code idiom in jsp