2014-09-14 2 views
-1

jsp의 프로젝트에서 작업 중이며 다음 줄에 오류가 발생했습니다. 전체 프로그램입니다. 오류는 다음과 같습니다.psp 프로그램의 오류

Session session = Session.getInstance(props, auth); 

오류 : 중복 로컬 변수 "세션". 이 오류를 해결하도록 도와주세요.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
pageEncoding="ISO-8859-1"%> 
<%@ page import = "com.mail.Restaurant.EmailUtil" %> 
<%@ page import=java.util.Properties,javax.*,javax.mail.Authenticator, 
javax.mail.PasswordAuthentication,javax.mail.Session %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org /TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<title>Insert title here</title> 
</head> 
<body> 
<% 
    final String Message = request.getParameter("Message"); 
    final String Name = request.getParameter("fname"); 
    final String Messageowner= ("Hi"+Name+","+"\n\n"+ 
    "You will be contactedshortly\n \n\n\n Regards,\n xyz.com"); 
    final String fromEmail = "[email protected]"; //requires valid gmail id 
    final String TID = request.getParameter("email"); 
    final String password = "password"; // correct password for gmail id 
    final String OwnerEmail = "[email protected]"; // can be any email id 
    final String Ownersubject=("Request from"+Name) ; 
    System.out.println("TLSEmail Start"); 
    Properties props = new Properties(); 
    props.put("mail.smtp.host", "smtp.gmail.com"); //SMTP Host 
    props.put("mail.smtp.port", "587"); //TLS Port 
    props.put("mail.smtp.auth", "true"); //enable authentication 
    props.put("mail.smtp.starttls.enable", "true"); //enable STARTTLS 

      //create Authenticator object to pass in Session.getInstance argument 
    Authenticator auth = new Authenticator() { 
     //override the getPasswordAuthentication method 
     protected PasswordAuthentication getPasswordAuthentication() { 
      return new PasswordAuthentication(fromEmail, password); 
     } 
    }; 
    Session session = Session.getInstance(props, auth); 

    EmailUtil.sendEmail(session, OwnerEmail,"Request from a Person", Message); 
    EmailUtil.sendEmail(session, TID,"Restaurant.com", Messageowner); 
    %> 
    </body> 
    </html> 
+0

변수'session'의 이름을 변경하십시오. –

답변

1

Jsp에는 미리 정의 된 값 집합이 있고 "session"은 그 중 하나입니다. 헤더 태그에 session = "false"를 설정하면 jsp- 컴파일러는 자체 세션 변수 선언을 포함하지 않아야합니다.