[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

HTTP status error 404

dear all below is a prog that tried to send an email using jsp

<%@ page import="java.sql.*, java.util.*, javax.mail.*, javax.mail.internet.*" errorPage="errorpsd.jsp, error.jsp, errornull.jsp, errorSameUsername.jsp" %>

<%
      String email = "danielchongboon@yahoo.com";
        String suggestion = "registration is successful";
        String topic = "Registraion is good";
        Properties props = new Properties();
       
        
         props.put("mail.smtp.host", "mail.server.com");
       Session s = Session.getInstance(props,null);

       MimeMessage message = new MimeMessage(s);

       InternetAddress from = new InternetAddress(email);//get address
       message.setFrom(from);
       InternetAddress to = new InternetAddress("danielchongboon@yahoo.com"); //to
       message.addRecipient(Message.RecipientType.TO, to);
       //InternetAddress cc = new InternetAddress("cc@towho.com");
       //message.addRecipient(Message.RecipientType.CC, cc);
 
       message.setSubject("Suggestion: " + topic);//get topic
       message.setText(suggestion);//message body

       Transport.send(message); //this is the problem
%>


but i got the following error...
description The requested resource (/errorpsd.jsp, error.jsp, errornull.jsp, errorSameUsername.jsp) is not available.

pls help
Thanks a million

0
ahnui79
Asked:
ahnui79
2 Solutions
 
kennethxuCommented:
>> you said you have those page but you don't:
errorPage="errorpsd.jsp, error.jsp, errornull.jsp, errorSameUsername.jsp" %>
0
 
anthony_castillonCommented:
I think you can only have one error page.  When you set all those jsp's as the value of errorPage, it evaluated everything inside the quotation marks as one URL.
0
 
cpuburstCommented:
Whatever be the case, you are getting an error in your page in the send mail code.
When the jsp encounters an error then it tries to find if there is an error page specified for any errors.
But when it tried to find the files listed for error forwarding, it gave another 404 error.
So please check ur mail sending code. That is where the error is.

Just remove the errorPage attribute and run the page. You will get the stack trace of the error on the console.

regards
cpuburst
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
cpuburstCommented:

I should also be getting a share in the split.
regards
Cpuburst
0
 
girionisCommented:
I believe there's nothing wrong with the source code. To my understanding the error lies to including multiple error files at once.
0
 
cpuburstCommented:
Hi,
You believe!!!,  but first you should verify ur knowledge of JSP, than guessing.

I have some sample code for you to test and understand.
As per your understanding, both the following code samples should fail. But actually only the second code alone fails.
Only when there is an error the page in the errorPage attribute is called. If that is not found, it results in page not found http 404 error.  So it turns out that my answer is the only completely correct answer. The error has to be in the code, than in the errorPage attribute declaration.  Now you decide what you should do with the points. Whether, I get the points or not is fine. But a wrong analysis shouldn't happen.

 
CODE Sample 1******************************************************************

<%@ page  errorPage="errorpsd.jsp, error.jsp, errornull.jsp, errorSameUsername.jsp" %>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title> Test</title>
</head>
<body>
Hello buddy <br>
<%= Integer.parseInt("12")%>
</body>
</html>

CODE SAMPLE 2 ***************************************************************

<%@ page  errorPage="errorpsd.jsp, error.jsp, errornull.jsp, errorSameUsername.jsp" %>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title> Test</title>
</head>
<body>
Hello buddy <br>
<%= Integer.parseInt("hello12")%>
</body>
</html>

**********************************************************************************
0
 
girionisCommented:
> As per your understanding, both the following code samples should fail.

Nope, only the second will fail since the JSP will never throw an error (and thus the error pages will never be called).

> Only when there is an error the page in the errorPage attribute is called.
>  If that is not found, it results in page not found http 404 error.

I never said otherwise.

Notice the question more carefully and see what the user asked (asterisks are mine):

>but i got the following error...
>description *****The requested resource (/errorpsd.jsp, error.jsp, errornull.jsp, errorSameUsername.jsp)*****
>is not available.

which means that it cannot find one of the error pages. I was probably wrong with my comment

>  including multiple error files at once.

and should have said it clearer:

> including multiple error files at once and one of them cannot be found.

So the only correct answer to the user's question is kennethxu's actually. If the user didn't have any error pages defined and was getting a different error message then your comment would have been correct but in this case it's not.

Or if you would like me to rephrase that. The user actually gets two (or more) error messages but the first one he needs to check on is whether the error page exists. After that he can check the rest of the error messages.
0
 
girionisCommented:
> Now you decide what you should do with the points

I do not decide who gets the points or not. I am just suggesting possible solutions.
0
 
girionisCommented:
> You believe!!!,

Yes I believe, I am not going to run every single example I see in order to be able to say what can possible be wrong or right.
0
 
cpuburstCommented:
>I believe there's nothing wrong with the source code. To my understanding the error lies to including multiple error files at once.
>I was probably wrong with my comment

Why don't you have a definite statement?.

I never said Kennethxu's answer is wrong. It is correct as far as errorpage attribute declaration is concerned.  
But I didn't want to give the author "ahnui79", an impression that it is only because of his errorPage declaration, his code failed. Actually the first error happened in his code, then only it came to errorpage attribute. Even though the first answer will solve the errorPage problem, again "ahnui79" will have another server error on his shoulders. So I feel an answer should be comprehensive and should deal with the root cause.

Girionis, you do what you feel is right. No more comments from my part on this.

Thanks and regards

Cheers
Cpuburst.
0
 
girionisCommented:
> Why don't you have a definite statement?.

It is easy to come to wrong conclusions if you only copy/paste half of my words.

> I never said Kennethxu's answer is wrong. It is correct as far as errorpage attribute declaration is concerned.  
> But I didn't want to give the author "ahnui79", an impression that it is only because of his errorPage declaration,

It is not only because of his errorPage declaration but *mainly* because of it. If the user *first* corrects the error page *then* he will get a different one.

I won't argue any more. I will let a moderator decide.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now