File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Custom Tags Page  496 HFSJ Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Custom Tags Page  496 HFSJ Question" Watch "Custom Tags Page  496 HFSJ Question" New topic
Author

Custom Tags Page 496 HFSJ Question

Harish Yerneni
Ranch Hand

Joined: Sep 15, 2004
Posts: 94
I can't print the subTitle attribute.

my url is http://localhost:8080/custags/contact.jsp
my output is ${subTitle}

**************
Code(contact.jsp)
**************
<%@ page isELIgnored="false" %>

<%@ taglib prefix="myTags" tagdir="/WEB-INF/tags" %>

<html><body>
<myTags:Header subTitle="we take the string out of soap" />
<br>
</body> </html>

*****
Header.tag
*****

<%@ attribute name="subTitle" required="true" rtexprvalue="true" %>

<em><strong> ${subTitle} </strong></em><br>

Any suggestions?

Thanks,

Harish


SCJP 1.4 | SCWCD 1.4 | SCJD (WIP)
Mat Williams
Ranch Hand

Joined: Jul 20, 2005
Posts: 215
Hi,

what version of container are you running? have you tried to stop the container and restart it? The reason I ask this is because when I copy your code and create the files in the same structure that you have it all works correctly for me

Mat
Harish Yerneni
Ranch Hand

Joined: Sep 15, 2004
Posts: 94
Interesting.

I am using Tomcat 5.0. I have restarted Tomcat and still got the same output. It is not recognizing EL, looks like.

contact.jsp path
D:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\custags

Header.tag path
D:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\custags\WEB-INF\tags

I have no other files like web.xml or any classes etc.

Any more thoughts?

Thanks,

Harish
Mat Williams
Ranch Hand

Joined: Jul 20, 2005
Posts: 215
Hi,

What is the web-app version in the web.xml file
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">


mine is 2.4 as you can see. Tomcat version 5.0.x uses 2.3 in all (I think) of their examples. So if you just copied one of thier examples, then EL is disabled by default, hence you need the directive
<%@ page isELIgnored="false" %>
in contact.jsp. If I change mine to version 2.3 then I get the same results that you do.

So make sure your web.xml is marked as version 2.4.

Mat
Mat Williams
Ranch Hand

Joined: Jul 20, 2005
Posts: 215
Hi again,

sorry I should have added that if you change the version, make sure you also change the schema localtion to point to the 2.4 schema.
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee <a href="http://java.sun.com/xml/ns/j2ee/web-app_<b rel="nofollow">2_4</b>.xsd"
" target="_blank">http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

Mat
Harish Yerneni
Ranch Hand

Joined: Sep 15, 2004
Posts: 94
my web.xml is

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright 2004 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">


<web-app>


<context-param>
<param-name>mainEmail</param-name>
<param-value>likewecare@wickedlysmary.com</param-value>
</context-param>

</web-app>
Harish Yerneni
Ranch Hand

Joined: Sep 15, 2004
Posts: 94
Mat,

Do I need a web.xml for this example to work?

-Harish
Mat Williams
Ranch Hand

Joined: Jul 20, 2005
Posts: 215
Hi,

Sorry for the delay in the reply. Change your web.xml to the following



you will then need to restart Tomcat or at least the context (easier to restart Tomcat) and all should work.

Mat
Mat Williams
Ranch Hand

Joined: Jul 20, 2005
Posts: 215
Hi,

Sorry I missed the point of your question. I don't believe that you do technically need a web.xml file for this. If I delete mine, and restart Tomcat, all seems to work fine. It will however depend on wether you add extra components to the app, ie servlets or Context Initialisation Parameters (as you currently have but are not using). If you add these, then yes you will need the web.xml. but just for jsp's and tag files no you don't.

HTH

Mat
Harish Yerneni
Ranch Hand

Joined: Sep 15, 2004
Posts: 94
Thanks, Mat.

I didnt use web.xml. Somehow, the same earlier code started working now.

-Harish
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom Tags Page 496 HFSJ Question