File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which of the following are valid JSP code fragments?

 
Amandeep Singh
Ranch Hand
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@ page import="java.util.*" autoFlush="true"%>
<%@ page import="java.io.*" autoFlush="false"%>

This is from enthuware.

According to me the the above should be correct. But i don't know why it is wrong?
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have multiple import attribute of page directive,but you can not have multiple "autoFlash" attribute.

Infact only import is the only attribute which can be duplicated.
 
Sanchita Srivastava
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes its true.we cant define Autoflush twice in a jsp page.

org.apache.jasper.JasperException: /hello.jsp(8,0) Page directive: illegal to have multiple occurrences of autoFlush with different values (old: true, new: false)
 
Joy Mukherjee
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However yu can have this directive in 2 different x and y files and
from x do a
<jsp:include page="y.jsp"/>

however cannot do
<%@ include file="y.jsp"%>

Thanks and Regards
JOy
 
Amandeep Singh
Ranch Hand
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When we say we can have multiple import attribute's, does that mean we use it like this

<%@page import ='java.util.*' import ='java.io.*'%>

Is this what means to have multiple import attribute's?
 
Sanchita Srivastava
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
multiple imports must be like..
<%@ page import="java.util.*, java.lang.*" %>
please check the following sun link http://java.sun.com/products/jsp/tags/11/syntaxref11.fm7.html
 
Joy Mukherjee
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Multiple import means same page has

<%@page import ='java.util.*' %>
<%@page import ='java.io.*'%>


Thanks and Regards
Joy
 
Amandeep Singh
Ranch Hand
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joy,

This is wrong answer from Enthuware.

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



And below your replie's says this. I am confused here. Is the above answer wrong because we first used autoFlush="true"
and then we used autoFlush="false"
-----------------------------------------------------------------
Multiple import means same page has

<%@page import ='java.util.*' %>
<%@page import ='java.io.*'%>

---------------------------------------------------------------------
 
Joy Mukherjee
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot use multiple "page directive with autoFlush attribute".
So Enthuware is correct that the answer is wrong.
However you can use
multiple page directive with the import attribute.Only import attribute is allowed with multiple page directive.
I hope this clears your doubt.


Thanks and Regards
Joy
 
Amandeep Singh
Ranch Hand
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks's Joy..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic