file « Parameter « JSP-Servlet Q&A

1. How do I access init parameters from a JSP2 tag file?

I'm trying to create a jsp tag file but it fails to compile when I try to use pageContext.getServletConfig().getInitParameter("myInitParam") I'm using tomcat and when I try to view a page including the ...

2. jsp java: my tag files don't replace parameters


<%@ attribute name="file" required="true"%>
<script type="text/javascript" src="/path/to/${file}"></script>
<%@ page language="java" contentType="text/html; charset=UTF-8"
<%@ taglib tagdir="/WEB-INF/tags" prefix="x"%>
<x:script file="register.js"/>
however, the ${file} param does not get replaced and stays literally ${file} Help!

3. tag file parameters

I created a tagfile and I want to have an either/or required parameter. In other words, you must specific 1 of 2 parameters. Any suggestions on how best to approach this? Right now I've just made them all optional and rely on myself to know that I need to specify one or the other. Thanks

4. Get parameter from web.xml file