We use JSPs (among other things) to build HTML and plain-text emails. In the plain-text JSPs, we have to be very careful of newlines when importing classes and taglibs.
What we've been doing is to end an import on the same line as we start the next one, like so:
<%@ page language="java" contentType="text/plain; charset=UTF-8" pageEncoding="UTF-8" %><%--
Forgive the funky formating BUT being a plain text email all
white space, including linebreaks for JSP tags gets carried over
to the final results!!!!
--%><%@
taglib uri="/tags/struts-bean" prefix="bean" %><%@
taglib uri="/tags/struts-logic" prefix="logic" %><%@
page import="java.util.*" %><%@
page import="foo.package.integration.value.*" %><%@
page import="foo.package.integration.value.languages.LanguageType" %><%@
page import="foo.package.integration.bd.*" %><%@
page import="foo.package.presentation.resource.DBConstants" %><%@
page import="foo.package.presentation.resource.MessageUtilities" %><%
Locale notificationLocale = (Locale) pageContext.getAttribute("notificationLocale");
Inspection inspection = (Inspection) request.getSession().getAttribute("inspection");
String survey = MessageUtilities.getMessageDetailForAnonymousSurvey(inspection, notificationLocale, false);
String appName = foo.package.presentation.resource.notification.NotificationBrander.getApplicationNameOrDefault(request);
%><bean:message key="notification.text.header.client.applicationName" arg0="<%= appName %>" locale="notificationLocale"/>
I would like to put all of these includes into one <%@ ... %>
block. Is that possible? If so, how?
<%@ page import="java.io.PrintWriter, java.io.FileOutputStream, java.io.File, etc... %>
Just use commas to separate the imports.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With