Solved

can't figure out namingException

Posted on 2007-11-27
4
1,121 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
designing in object programming 12 94
tomcat startup error 5 106
java imports not found 4 30
American Express @Work site and Java 4 32
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

821 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