App Engine表单提交返回服务器上的JSP表单错误

时间:2018-08-10 11:02:03

标签: java html jsp google-app-engine java-web-start

我已经在App Engine上部署了Java Web应用程序,以前的版本可以使用,我只是在HTML和JS文件中进行了一些更改,然后重新部署了新版本,但是现在联系表格不起作用,它返回此错误为:

  

错误:服务器错误

     

服务器遇到错误,无法完成您的请求。

     

请在30秒内重试。

这是我的JAVA servlet代码:

package com.unmundonuevo;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.*;

import com.google.appengine.labs.repackaged.org.json.JSONException;

@SuppressWarnings("serial")
public class UnmundonuevoServlet extends HttpServlet {
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        // set credentials
        Sendgrid mail = new Sendgrid("UNAME", "UPASS");
String name=req.getParameter("name");
String email=req.getParameter("email");
String subject=req.getParameter("subject");
String message=req.getParameter("message");

        // set email data
        mail.setTo(email).setFrom("EMAIL").setSubject("Your request has been submitted successfully")
        .setHtml("<strong>Hello " 
                + "!</strong><br><br> We appreciate you contacting us, We will be in touch very soon.<br><br>Thank you <br> Nelly & Sandy");

        // send your message
        try {
            mail.send();
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


        Sendgrid mail1 = new Sendgrid("UNAME", "UPASS");

        mail1.setTo("umnsica@gmail.com").setFrom("EMAIL").setSubject("New contact request from http://www.unmundonuevo.school")
        .setText("Hello World!")
        .setHtml("<strong>Hello " 
                + "!</strong>"
                + "<br><br> "+name+" sent a message on unmundonuevo.school. "
                + "<br>Email : " + email +  
                "<br>Subject : " + subject + 
                "<br>Message : "+message+"");

        // send your message
                try {
                    mail1.send();
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }


          PrintWriter out = resp.getWriter();

          resp.setContentType("text/html");

            resp.setHeader("Refresh", ".1; url=/index.jsp?message=Mail Sent Successfully#contact");


    }
}

这是我的 web.xml

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
    <servlet>
        <servlet-name>Unmundonuevo</servlet-name>
        <servlet-class>com.unmundonuevo.UnmundonuevoServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Unmundonuevo</servlet-name>
        <url-pattern>/unmundonuevo</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

这是我的HTML表单:

<!-- Form Starts -->
<div id="contact_form">
   <h4 align="center"  ><font color="#8BC34A"><%if(request.getParameter("message") != null){%><%=request.getParameter("message") %><%} %></font></h4> 
   <form action="unmundonuevo" method="post"  >
         <div class="form-group">
                        <input type="text" name="name" class="form-control input-field" placeholder="Name" required="">
                        <input type="email" name="email" class="form-control input-field" placeholder="Email ID" required="">
                        <input type="text" name="subject" class="form-control input-field" placeholder="Subject" required="">
           </div>
     <textarea name="message" id="message" class="textarea-field form-control" rows="4" placeholder="Enter your message" required=""></textarea>
      <button type="submit" id="contactform" value="Submit" class="btn center-block">Send message</button>

    </form>
</div>

请帮帮我!

谢谢!

0 个答案:

没有答案