JSP Tag

back to index

Introduction

Finally, a JSP Tag called "convert" is included with the distribution so that you can perform Java-to-HTML conversion seamlessly in web pages.

The JSP tag can get its input from its body, from an external file, an URL or any InputStream.

Sample Usage

In order to use the JSP Tag, you must specify at least one skin (CSS stylesheet) to use. The source code to convert is indicated using the input attribute. If it is missing, then the tag body is assumed to be the source code to convert.

<c2w:convert  skins="Eclipse,styles/eclipse.css" language="Java">
source code to convert </c2w:convert>

The input attribute maybe a java runtime expression of the following types:

<c2w:convert  input="WEB-INF/source/Test.java" .... />  
<c2w:convert  input='<%= new URL("http://snippetserver.com/Foo.java") %>' .... />  
<c2w:convert  input='<%= new FileInputStream("c:/Test.java")  %>' .... />  

A sample jsp page (test.jsp) is included with the distribution to illustrate a complete invocation.

Specific JSP attributes

The JSP tag has a specific attribute, called useFileNameAsTitle, that instructs the JSP tag to present the file name as title of the source code. This setting is useful when placed inside a common configuration file:

#
# Sample configuration file (java2web.properties)
#
language=Java
showLineNumbers=false
...
useFileNameAsTitle=true	
	

Later, you can refer to this configuration file using the general config property.

<c2w:convert input="FrameReader.java" config="/java2web.properties" showLineNumbers="true"/>

Note that settings specified on each tag override the general ones (in the global configuration file, showLineNumbers is set to false, but in the tag it is set to true, and the latter takes preference)