5.5.1 Changing the JSP used for the View mode
Follow these steps to see how the JSPs can be modified to show dynamic information:
1. Double-click HelloWorldPortletView.jsp from the /WebContent/helloworld/jsp/html/ directory in the Project Explorer view.
Figure 5-25 View.jsp
2. Click the Source tab at the bottom of the editor to see the source code.
Figure 5-26 Editing JSP source
3. Add the following source code to the HelloWorldPortletView.jsp. Example 5-1 View JSP source edit
<%@ page session="false" contentType="text/html" import="java.util.*, helloworld.*"%> <%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="portletAPI" %> <portletAPI:init/> <DIV style="margin: 6px">
<H3 style="margin-bottom: 3px">Welcome!</H3> This is a sample <B>view mode</B> page. You have to edit this page to customize it for your own use.<BR> The source file for this page is "/Web Content/helloworld/jsp/html/HelloWorldPortletView.jsp".
<br> Current time: <%=new java.util.Date() %> <br> Hostname: <%= request.getRemoteHost()%> ...
![]()
4. Save all of your changes by clicking File | Save All.
5. Again, right-click your project in the Project Explorer view. Then click Run | Run on Server.
Figure 5-27 Run on server
6. Choose your existing WebSphere Portal V5.1 Test Environment. You can click Finish to run the project in the Web browser since you have already configured this server to work with this project.
Figure 5-28 Running your project in the test environment
7. Observe your changes in the Web browser.
Figure 5-29 Changes in the View JSP
ibm.com/redbooks