Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with my jsp page

 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i using bean file for my jsp page. but when i run the jsp page, the error come out:
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
string cannot be resolved to a type

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
string cannot be resolved to a type

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
string cannot be resolved to a type

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
string cannot be resolved to a type

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
string cannot be resolved to a type

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
string cannot be resolved to a type

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
string cannot be resolved to a type

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
string cannot be resolved to a type


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:409)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

i donno how to solve it. here i post my jsp code with my bean code.i creating a send mail application.
JSP CODE:
<%@page import="java.sql.*,java.text.*,java.util.*,java.util.Vector,javax.mail.*" %>
<%@page import="java.sql.*,java.lang.Object,java.lang.String,java.lang.Integer,java.util.*,java.text.SimpleDateFormat, java.text.*"%>
<jsp:useBean id="send" type="common.sendMail"/>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<% string to=request.getparameter("toadd");
string bcc=request.getparameter("bccadd");
string cc=request.getparameter("ccadd");
string subject=request.getparameter("sub");
string file=request.getparameter("datafile");
string content=request.getparameter("content");
string host=request.getparameter("host");
string sender="ken03leo@yahoo.com";
%>

<html>
<head>
<title>sending mail</title>
</head>
<body>
<%
send.sending(host,sender,to,cc,bcc,subject,content,file);
%>

</body>
</html>

BEAN CODE:
package common;
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;


public class sendMail{
public void sending(String SMTPServer,
String Sender,
String Recipient,
String CcRecipient,
String BccRecipient,
String Subject,
String Body,
String Attachments){
// Get system properties

Properties props = System.getProperties();

// Setup mail server
props.put("mail.smtp.host", SMTPServer);

// Get session
Session session = Session.getDefaultInstance(props, null);

// Define message
MimeMessage message = new MimeMessage(session);
try
{
message.setFrom(new InternetAddress(Sender));
{
InternetAddress[] TheAddresses = InternetAddress.parse(Recipient);
message.addRecipients(Message.RecipientType.TO,TheAddresses);
}
if (null != CcRecipient) {
InternetAddress[] TheAddresses = InternetAddress.parse(CcRecipient);

message.addRecipients(Message.RecipientType.CC,TheAddresses);
}
if (null != BccRecipient) {
InternetAddress[] TheAddresses = InternetAddress.parse(BccRecipient);

message.addRecipients(Message.RecipientType.BCC,TheAddresses);
}


message.setSubject(Subject);
// Create the Multipart to be added the parts to
Multipart mp = new MimeMultipart();

// Create and fill the first message part
{
MimeBodyPart mbp = new MimeBodyPart();
mbp.setText(Body);

// Attach the part to the multipart;
mp.addBodyPart(mbp);
}

// Attach the files to the message
if (null != Attachments) {
int StartIndex = 0, PosIndex = 0;
while (-1 != (PosIndex = Attachments.indexOf("///",StartIndex))) {
// Create and fill other message parts;
MimeBodyPart mbp = new MimeBodyPart();
FileDataSource fds =
new FileDataSource(Attachments.substring(StartIndex,PosIndex));
mbp.setDataHandler(new DataHandler(fds));
mbp.setFileName(fds.getName());
mp.addBodyPart(mbp);
PosIndex += 3;
StartIndex = PosIndex;
}
// Last, or only, attachment file;
if (StartIndex < Attachments.length()) {
MimeBodyPart mbp = new MimeBodyPart();
FileDataSource fds = new FileDataSource(Attachments.substring(StartIndex));
mbp.setDataHandler(new DataHandler(fds));
mbp.setFileName(fds.getName());
mp.addBodyPart(mbp);
}
}

// Add the Multipart to the message
message.setContent(mp);

// Set the Date: header
message.setSentDate(new Date());

// Send the message;
Transport.send(message);
}

catch (MessagingException e)
{
System.err.println("Caught Exception: "
+ e.getMessage());

}

}
}


i already put my bean class file into the common folder. can some one help me to resolve this thank you
*note i shoulld pass in the value from another html form page. i sure that the name that i give to the form field is similar to the jsp getparameter name.

thank you.

regards,
albert
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's String, not string.

I'd also strongly advise you to move your java code out of the JSP page and completely into beans and/or servlets. It'll not only make for a better program structure, it will make debugging 500% easier.
 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i already change the string to String. but the same error come out how to solve it. i already no idea to solve it. Pleas...Please... help me
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show us the new error messages. if you changed the page they have to have changed.

Alos please use the UBB code tags when posting code examples (see the CODE button on the reply page) to enclose code and preserve its formatting.
 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
error is:
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest

An error occurred at line: 6 in the jsp file: /send/send.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:409)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

bean file:


JSP code:
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is Java. That means that identifiers, class names and method names are case sensitive.

Check the APIs and make sure you are using the correct spelling and casing of all elements.
 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya i already check and make sure the variable... is ok
but it's still have error.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method getparameter(String) is undefined for the type HttpServletRequest


You didn't check very well.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I've already answered this one in an another forum...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh no, same forum, different thread called "unable to compile class"
 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i post two threat for same forum i think you better answer my unable to compile class threats thank you
 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i solve all the error already. But when i do the testing for my send mail application, the email cannot reach the recipient. here i post my code, if i code something wrong please tell me thank you.

Form Code:

this is my form code. i need to go in to this page to do my key in address message body and so on and i using smtp.mail.yahoo.com as my host.

send.jsp


the jsp will call the bean file to send out the message. in the jsp will pass in the relevent information to sending message.

BEAN CODE:

this is the bean file that use to send out the message to the recipient.
please help me to figure out the problem i know you are the expert and experience in java field. i'm just the trainee in a company that first time using the java to do a program. Please Help Me Please....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic