About Question enthuware.jwpv6.2.1024 :

Moderator: admin

Post Reply
ETS User

About Question enthuware.jwpv6.2.1024 :

Post 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>...

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1024 :

Post 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.
If you like our products and services, please help us by posting your review here.

harsh.sahajwani
Posts: 13
Joined: Sun Jan 20, 2013 5:58 am
Contact:

Re: About Question enthuware.jwpv6.2.1024 :

Post 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?

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1024 :

Post 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.
If you like our products and services, please help us by posting your review here.

grendel777@o2.pl
Posts: 4
Joined: Mon Jan 11, 2016 1:52 pm
Contact:

Re: About Question enthuware.jwpv6.2.1024 :

Post by grendel777@o2.pl »

What about putting scriplet code inside custom tag body, isn't it forbidden?

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1024 :

Post 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.
If you like our products and services, please help us by posting your review here.

grendel777@o2.pl
Posts: 4
Joined: Mon Jan 11, 2016 1:52 pm
Contact:

Re: About Question enthuware.jwpv6.2.1024 :

Post by grendel777@o2.pl »

Aghr, right! Forgot :)

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.jwpv6.2.1024 :

Post 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>


Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests