Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I combine multiple imports in a JSP?

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?

like image 763
Martin Avatar asked Dec 02 '14 19:12

Martin


1 Answers

<%@ page import="java.io.PrintWriter, java.io.FileOutputStream, java.io.File, etc... %>

Just use commas to separate the imports.

like image 185
brso05 Avatar answered Sep 23 '22 00:09

brso05