Page 1 of 1

About Question enthuware.jwpv6.2.1024 :

Posted: Fri Nov 16, 2012 6:30 am
by ETS User
My question is: where is guarantee, that body of the tag will be processed? I was little confused, because <body-content> could be set to tagdepandent. So there is no guarantee (only posibility) to print correct output... What is wrong with my assumption?
From my point of you in question should be word "could", or info about <body-content>...

Re: About Question enthuware.jwpv6.2.1024 :

Posted: Sun Nov 18, 2012 7:55 am
by admin
In the context of the question, I think your assumption is kind of on the borderline between valid and invalid :) A question cannot specify everything. Anything that is not specified should be assumed to not affect the answer. For example, where is the guarantee that scripting is enabled on the page? It is possible to disable it in the deployment descriptor in which case the give fragment will not work.

The actual exam also expects you to make similar assumptions i.e. if anything is not specified in the question then it should be assumed to be ok.

We have updated the question as per your suggestion.

Re: About Question enthuware.jwpv6.2.1024 :

Posted: Wed Jan 23, 2013 11:01 pm
by harsh.sahajwani
Which version of JSP spec should be studied for OCEJWCD 1Z0-899 exam?

Where can I download pdf version of that JSP spec from?

And which section or page number provides details for variables that are set for custom tags, as asked in this question?

Re: About Question enthuware.jwpv6.2.1024 :

Posted: Thu Jan 24, 2013 6:08 am
by admin
JSP 2.2 You can download it from Oracle.
Take a look at chapter titled "Package javax.servlet.jsp.tagext" page 1-69
HTH,
Paul.

Re: About Question enthuware.jwpv6.2.1024 :

Posted: Sun Jan 17, 2016 4:09 pm
by grendel777@o2.pl
What about putting scriplet code inside custom tag body, isn't it forbidden?

Re: About Question enthuware.jwpv6.2.1024 :

Posted: Mon Jan 18, 2016 8:47 am
by admin
grendel777@o2.pl wrote:What about putting scriplet code inside custom tag body, isn't it forbidden?
No, it is not forbidden for classic tags. For simple tags (i.e. tags implementing SimpleTag interface or tags based on tag Files), it is forbidden.
HTH,
Paul.

Re: About Question enthuware.jwpv6.2.1024 :

Posted: Mon Jan 18, 2016 3:43 pm
by grendel777@o2.pl
Aghr, right! Forgot :)

Re: About Question enthuware.jwpv6.2.1024 :

Posted: Mon May 09, 2016 10:49 pm
by himaiMinh
This is an example to demonstrate this random number tag:

Code: Select all

package com.tags;

 
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.*;
 
public class RandomNumberGen extends TagSupport {
     public Double randomValue;
     @Override
    public int doStartTag() throws JspException {
          randomValue = Math.random();
          pageContext.setAttribute("value", randomValue.toString());
         
    return EVAL_BODY_INCLUDE;
    }
       
}

Code: Select all

package com.tei;

import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.TagExtraInfo;
import javax.servlet.jsp.tagext.VariableInfo;
 
public class MyTEI extends TagExtraInfo {
    public VariableInfo[] getVariableInfo(TagData data){
         VariableInfo[] values = new VariableInfo[1];
         values[0] = new VariableInfo("value", "java.lang.String", true, VariableInfo.NESTED);
     return values;
    } 
}

Code: Select all

<taglib version="2.1" xmlns="http://java.sun.com/xml/ns/javaee" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">
  <tlib-version>1.0</tlib-version>
  <short-name>mytld</short-name>
  <uri>http://www.mytlds.com</uri>
   
    <tag>
        <name>randomNum</name>
        <tagclass>com.tags.RandomNumberGen</tagclass>
        <body-content>JSP</body-content>
        <tei-class>com.tei.MyTEI</tei-class>
    </tag>
  </taglib>
Index.jsp:

Code: Select all

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
    <body>    
        <%@ taglib prefix="my" uri="http://www.mytlds.com" %>    
        <my:randomNum><%=value%></my:randomNum>
    </body> 
 </html>