[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

can't figure out namingException

Posted on 2007-11-27
4
Medium Priority
?
1,224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

656 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