Solved

can't figure out namingException

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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:

724 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