Personalización avanzada > Info*Engine User's Guide. Nota: Este manual no se encuentra disponible en español. > Info*Engine JSP Pages
  
Info*Engine JSP Pages
The following topics introduce the concept of an Info*Engine JSP page and describe how to use Info*Engine custom tags.
Authoring Info*Engine JavaServer Pages
JavaServer Pages (JSP) is a core technology of the Java Platform, Enterprise Edition (Java EE) and solutions based upon EJB (Enterprise Java Beans). Info*Engine supports the development of enterprise custom Java applications and provides a JSP processor as an extension of the Info*Engine servlet engine. The JSP processor dynamically translates JSP pages into servlets.
Usually, a JSP page is an HTML page with some additional JSP tags and some embedded Java code. However, inclusion of JSP tags or embedded Java is not mandatory, so a page containing only HTML is a legitimate JSP page.
JSP pages that interact with Info*Engine usually contain a simple set of JSP tags and a set of custom Info*Engine tags that define the webjects that are then executed when the page is accessed. For example, the following DisplayTable.jsp page creates a group containing one element and displays the table-formatted results:
<%@page language="java"  session="false"
  errorPage="IEError.jsp"%>

<%@ taglib uri="http://www.ptc.com/infoengine/taglib/core" prefix="ie" %>

<html>
<head>
<title>JSP Display-Table</title>
</head>

<body bgcolor="#FFFFFF">
<h3> I*E Display-Table JSP Using Taglibs <h3>

<ie:webject name="Create-Group" type="GRP">
  <ie:param name="ELEMENT"
     data="name=myGroup2:email=xxx@xxx.com:address=PTC"/>
  <ie:param name="GROUP_OUT" data="newGroup2"/>
</ie:webject>

<ie:webject name="Display-Table" type="DSP"/>

</body>
</html>
* 
Due to the upgrade to the latest JSP specification, JSPs using Info*Engine substitution syntax can no longer use the ${...} syntax. Info*Engine now supports an alternate syntax, $(...) that must be used instead. All Info*Engine tasks now function with either a syntax of $(...) or ${...}. Preexisting tasks continue to function as is and do not have to be changed. Preexisting JSPs must be updated to use the new $(...) syntax or they fail to compile and do not function as expected.
For more information, see Using the Info*Engine Task Editor.
Storing Info*Engine JSP Pages
The root of the Windchill web application is <Windchill>/codebase, and therefore all Info*Engine JSPs must be stored somewhere within that codebase directory. Ideally, you should create a directory hierarchy to organize your JSPs, such as <Windchill>/codebase/com/company/.
Accessing Info*Engine JSP Pages
The installer also specifies an application URL that is used as the URL prefix for requesting Info*Engine JSP pages. You can produce the URL that contains the request to execute Info*Engine JSP pages by doing the following:
Include the host name and port (if the port is not the default), and the application URL prefix specified when Info*Engine was installed. The default application URL is “Windchill.”
Name the path for the JSP page that is relative to the codebase directory.
Specify any optional values to pass to the page.
Therefore, to execute the com/company/DisplayTable.jsp page using the “myServer” host name and the “Windchill” application URL, specify the following URL:
http://myServer/Windchill/com/company/DisplayTable.jsp
The output displayed in the browser is similar to the following:
Usually, a web server supporting JSP is configured so that it recognizes any file name with the .jsp extension as a JSP page. When a URL references this type of file, the web server passes the URL to its JSP processor. The JSP processor then checks to see if it already has a servlet for this page. If not, it automatically translates the page to a servlet and then executes that servlet. If the page contains only HTML, the generated servlet is trivial and consists of one or more Java print statements that simply send the HTML to the browser. If, on the other hand, the JSP page contains some embedded Java code, that code is incorporated directly into the servlet that is generated.
If the JSP processor detects that it already has a servlet for the URL that has been passed to it, then it checks to see if the page has been modified since the last time that the servlet was generated. If it detects that the page has been updated since the last servlet generation, it automatically regenerates the servlet. Otherwise, it reuses the previously generated servlet.
Creating Info*Engine JSP Pages
Each Info*Engine JSP page should contain the following items:
The standard JSP page directive, which defines the general page characteristics.
The standard JSP taglib directive, which identifies a tag library containing Info*Engine custom tags.
You must put this directive before any lines that use the custom tags in the library.
Info*Engine custom tags, which provide access to a set of custom actions that encapsulate recurring functionality.
The custom tags provide the syntax for executing webjects and provide the structure around which you can build a JSP.
To be well-formed and valid, the Info*Engine JSP pages must follow basic JSP rules:
For Info*Engine custom tags and JSP tags, you must use lowercase. For example, you must specify the webject tag as “webject” and not “WEBJECT” or “Webject” or even “webJecT”.
You can use comments to document what is happening in your page or to cause the compiler to skip a section of the page. If a webject is surrounded by a comment, it is not executed. Comments can be located anywhere in a task except within tags, declarations, or other comments.
Comments begin with <!-- and end with -->.
Empty elements must be properly constructed. The trailing /> characters (the forward slash followed by the right angle bracket) in the JSP syntax indicates that the element is empty and no matching end tag should be sought. For example, the param custom tags make use of the empty element construction.
Additional general rules for using scriptlets, expressions, declarations, directives, and Info*Engine custom tag elements can be found in the Info*Engine Custom Tag Reference.
The example DisplayTable.jsp page includes the following standard JSP directives:
IEError.jsp as the standard page directive. It contains a reference to the example error page:
<%@page language="java"  session="false"
  errorPage="IEError.jsp"%>
The ie prefix as the required prefix. The prefix identifies the tag as belonging to the core tag library, which provides the general custom tags that can be used in a JSP page:
<%@ taglib uri="http://www.ptc.com/infoengine/taglib/core"
           prefix="ie" %>
The previous DisplayTable.jsp page also includes the webject and param custom tags:
The webject tags identify the Create-Group and Display-Table webjects.
The param tags supply webject parameters and parameter values.
For the Create-Group webject, the parameters define the name of the output group and the attributes and values of elements in the group.
An Info*Engine JSP page can also contain any supported HTML and JSP tag. This guide does not describe the HTML and JSP tags that you can use. To review the supported tags, you can access the following sites:
http://java.sun.com
http://www.w3.org/
Executing Tasks from JSP Pages
Although you can include any webject in a JSP page, you might want to separate the webjects that generate and manipulate data from those that display data. This is done by creating text-based documents called standalone tasks and executing the tasks through the Info*Engine task tag. The uri attribute on the task tag names the task to execute.
Info*Engine Tasks describes how to create and use tasks.