Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java “JSP错误”;“类型”的非法启动;_Java_Jsp_Servlets - Fatal编程技术网

Java “JSP错误”;“类型”的非法启动;

Java “JSP错误”;“类型”的非法启动;,java,jsp,servlets,Java,Jsp,Servlets,我正在尝试为运行的HTML表单获取JSP文件,但遇到以下问题: 当我尝试在testserver(使用LiveLink运行)上运行此文件时,会出现一个错误,说明: 500 Servlet异常 /WebApps_e/WebApps/FORMS/Formular_Softwareantrag/PDFTest/PDFTest.jsp:34: 类型的非法开始 尝试 ^ f:\wcm\WEB\WEB-INF\work\\U jsp\\U webapps\U 0e\\U webapps\\U forms\\

我正在尝试为运行的HTML表单获取JSP文件,但遇到以下问题: 当我尝试在testserver(使用LiveLink运行)上运行此文件时,会出现一个错误,说明:


500 Servlet异常
/WebApps_e/WebApps/FORMS/Formular_Softwareantrag/PDFTest/PDFTest.jsp:34:
类型的非法开始
尝试
^
f:\wcm\WEB\WEB-INF\work\\U jsp\\U webapps\U 0e\\U webapps\\U forms\\U formular\U 0softwareantrag\\U pdftest\\U pdftest\U jsp。java:319:
预期
private java.util.ArrayList_caucho_dependens=new java.util.ArrayList();
^
2个错误

这就是我的JSP文件的样子

<%@ page import="
java.util.*,
java.util.HashMap,
java.net.URL,
java.io.*,
javax.mail.*,
javax.mail.internet.*,
javax.activation.*,
de.gauss.vip.portalmanager.VipObjectBean,
de.gauss.vip.repository.RepositoryEntry,
de.gauss.lang.StringValue,
de.gauss.vip.api.admin.Server,
com.lowagie.text.*,
com.lowagie.text.pdf.*,
com.caucho.vfs.*
" %>
<%!
HashMap pdfOutputs = new HashMap();
Document document = null;
PdfReader reader = null;
PdfStamper stamper = null;
AcroFields acro_fields = null;
ByteArrayOutputStream bostream = null;

try
{
    vobFORMS.setRepositoryName("{VIPDEPLOYMENT_NAME}");
    vobFORMS.addDefaultAttribute("pathname");

    /** Check for standart attributes */
    String template = request.getParameter("TEMPLATE");
    if (template == null)
    {
        throw new Exception("TEMPLATE-Parameter fehlt!");
    }

    /** Collecting the parameters in a HashMap */
    Enumeration param_names_enum = request.getParameterNames();
    while (param_names_enum.hasMoreElements())
    {
        String param = (String)param_names_enum.nextElement();
        if (param != null)
        {
            /** Wert des Parameters holen */
            String param_value = request.getParameter(param);
            if (param_value != null)
            {
                pdfOutputs.put(param, param_value);
            }
        }
    }

    /** Handling the Data */
    /** 1. Load the PDF-Template */
    String filename = null;
    RepositoryEntry repHelp = vobFORMS.getEntry(template);

    if (repHelp != null)
    {
        filename = ((StringValue)repHelp.getValue("pathname")).getString();
    }
    if (filename == null)
    {
        throw new Exception("PDF-Template could not be found!");
    }

    reader = new PdfReader(filename);
    int rotation = reader.getPageRotation(1);

    if (rotation == 90 || rotation == 270)
    {
        document = new Document(PageSize.A4.rotate());
    }
    else
    {
        document = new Document(PageSize.A4);
    }

    /** 2. Appending the writer */
    bostream = new ByteArrayOutputStream();
    PdfWriter writer = PdfWriter.getInstance(document, bostream);

    /** 3. Opening the Document */
    document.open();

    /** 4. Appending the content */
    PdfContentByte cb = writer.getDirectContent();
    PdfImportedPage pdfpage = writer.getImportedPage(reader, 1);

    if (rotation == 90 || rotation == 270)
    {
        cb.addTemplate(pdfpage,0,-1,1,0,0,595f);
    }
    else
    {
        cb.addTemplate(pdfpage,1,0,0,1,0,0);
    }

    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
    cb.beginText();
    cb.setFontAndSize(bf, 12);

    stamper = new PdfStamper(reader, pdfpage);
    acro_fields = stamper.getAcroFields();

    /** Iteration through the HashMap */
    for (String key : pdfOutputs.keySet())
    {
        acro_fields.setField(key, pdfOutputs.get(key));
    }

    /** End of the form-fields */
    cb.endText();

    /** 5. Closing the document */
    document.close();
}
catch(Exception ex1)
{
    out.println("An Error occured while handling the data<br>");
    out.println(ex1.getMessage());
}
finally
{
    if (stamper != null)
        stamper.close();
    if (pdfOutputs != null)
        pdfOutputs.clear();
    if (reader != null)
        reader = null;
    if (document != null)
        document.close();
    if (bostream != null)
        bostream.close();
}
%>

我已经检查了是否缺少括号,但据我所知,没有遗漏任何括号

我不知道这是否重要,但服务器正在运行Java1.4.2_19(无法更新),正如您所看到的,JSP还包含iText功能


是我在代码本身中犯了错误,还是原因与我没有想到的不同?

这应该是一个servlet,而不是JSP。JSP应该包含HTML代码和JSP标记。不是Java代码

关于您的问题:您的代码被转换为如下所示的类:

public class TransformedJsp {
    HashMap pdfOutputs = new HashMap();
    // ...

    try {
        //...
这显然是无效的。try块必须位于方法内部。不是直接在课堂上


但我重复一遍:不要对Java代码使用JSP。使用servlet。这就是他们的目的。

这应该是一个servlet,而不是JSP。JSP应该包含HTML代码和JSP标记。不是Java代码

关于您的问题:您的代码被转换为如下所示的类:

public class TransformedJsp {
    HashMap pdfOutputs = new HashMap();
    // ...

    try {
        //...
这显然是无效的。try块必须位于方法内部。不是直接在课堂上


但我重复一遍:不要对Java代码使用JSP。使用servlet。这就是他们的目的。

谢谢你的快速回复,那会有帮助的。谢谢你的快速回复,那会有帮助的