• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What does the following statement means?

 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any page directive except import can only occur only once.

Why the following JSP code wrong?
<%@ page import="java.util.*" autoFlush="true"%>
<%@ page import="java.io.*" autoFlush="false"%>

Can any body help me to understand this?
[ May 14, 2008: Message edited by: Shashidhar Rao ]
 
Shashidhar Yarabati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
does the above means autoflush repeated twice, and this should not be done?

Am I right guys?
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think you are right since import statement can be more than once in jsp page

Regards
Sravanthi
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, multiple occurences of attributes other then import is allowed, provided there values remain the same
For eg:
<%@ page import="java.util.*" autoFlush="true"%>
<%@ page import="java.io.*" autoFlush="true"%>

is allowed

whereas below is not allowed:
<%@ page import="java.util.*" autoFlush="true"%>
<%@ page import="java.io.*" autoFlush="false"%>

(the above gives the following error in tomcat 6
Page directive: illegal to have multiple occurrences of autoFlush with different values (old: true, new: false)
)
 
Shashidhar Yarabati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But I saw some where that Any page directive except import can only occur only once.

Is it wrong???
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Page directives can occur multiple times, as long as the values are the same. The following is from the JSP 2.0 spec on page directives:

There shall be only one occurrence of any attribute/value pair defined by this directive in a given translation unit, unless the values for the duplicate attributes are identical for all occurrences. The import and pageEncoding attributes are exempt from this rule and can appear multiple times.
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Import is the page directive that is used to import different packages in to the jsp. Which means that you have as my page directive's as you want in a single directory.

But if you look at the other directives, almost all of them are to set a particular property corresponding to the jsp. There is not meaning in having two page directives with different values.

for example....

autoFlush if set to true,the buffer output will be flushed whenever the buffer is full and vice versa.



In this case, there is no meaning if you declare autoFlush two times with controversial values. So, your code mentioned above can be changed some like below.

1)



2)


You may want to check this usefull article about page directives. Hope this helps....
[ May 17, 2008: Message edited by: Prasad Tamirisa ]
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

<%@ page import="java.util.*" autoFlush="true"%>
<%@ page import="java.io.*" autoFlush="false"%>


My understanding, the above two lines of code will be eventually interpreted as a single line, like below:

<%@ page import="java.util.*" autoFlush="true" import="java.io.*" autoFlush="false"%>


if you observe JSP spec, it mentioned that import can occur multiple times, other attributes can also occur multiple times but with same values.

if you change your code as blow :

<%@ page import="java.util.*" autoFlush="true"%>
<%@ page import="java.io.*" autoFlush="true"%>


it will be interpreted as :

<%@ page import="java.util.*" autoFlush="true" import="java.io.*"%>


which is leagal
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic