Solved

can't figure out namingException

Posted on 2007-11-27
4
1,116 Views
Last Modified: 2008-02-01
I get the error shown below. It is repeated twice more for lines 27 and 28. I use these exact same three lines of code in various other places in my jsp pages. The only difference is these particular lines are include in a subroutine (<%! ... %>) whereas the others are in-line in the jsp page. What is my problem??!! I'm so confused!

An error occurred at line: 26 in the jsp file: /include/email.inc
Unhandled exception type NamingException
23:    
24:     if ((from == null) || (from.length() == 0))
25:     {
26:           Context ctx = new javax.naming.InitialContext();
27:           Context env = (Context) ctx.lookup("java:comp/env");
28:       replyAddr = (String) env.lookup("webUser");
29:       

0
Comment
Question by:jmarkfoley
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 20362337
you need to put it ina  try/catch block

try
{
           Context ctx = new javax.naming.InitialContext();
           Context env = (Context) ctx.lookup("java:comp/env");
       replyAddr = (String) env.lookup("webUser");
}
catch (NamingException ex)
{
   // handle exception
}
0
 
LVL 5

Expert Comment

by:deeppra
ID: 20363093
Your are getting the same error message when u place these lines inline jsp
0
 
LVL 1

Author Comment

by:jmarkfoley
ID: 20363759
So, explain why I need a try/catch block in a subroutine, but not in the "main" program? Is there an implied try/catch on the main page?
0
 
LVL 92

Expert Comment

by:objects
ID: 20363873
>  Is there an implied try/catch on the main page?

yes. though its not really implied. the generated method is defined to handle the exception.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 96
JDeveloper 12c for 32 bit 4 84
java 8 lambda expresssions exception handling 3 89
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 33
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question