*
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 Android Security Essentials Live Lessons this week in the Android 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: 60785
    
  65

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: 860

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: 60785
    
  65

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: 41128
    
  45
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.


Ping & DNS - my free Android networking tools app
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

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 .
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: weird code idiom in jsp
 
Similar Threads
How to use JSTL varraible in to jsp
Javascript Menu display on mouseover
How to map onclick to another input element
problem with &lt script &gt tag
Checking if browser supports JAVASCRIPT and COOKIES...