Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8301997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:10:35+00:00 2026-06-08T17:10:35+00:00

what is meant by java:comp/env ? What does the look up like : Context

  • 0

what is meant by java:comp/env ?

What does the look up like :

Context envContext = (Context)initContext.lookup("java:comp/env");

do ?

I understand that a look-up like :

(DataSource)envContext.lookup("jdbc/MyDatasource")

looks up for the name MyDatasource in the context.xml or web.xml to get the URL of the database. Is it so ? !! But what does the former look up do ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:10:36+00:00Added an answer on June 8, 2026 at 5:10 pm

    java:comp/env is the node in the JNDI tree where you can find properties for the current Java EE component (a webapp, or an EJB).

    Context envContext = (Context)initContext.lookup("java:comp/env");
    

    allows defining a variable pointing directly to this node. It allows doing

    SomeBean s = (SomeBean) envContext.lookup("ejb/someBean");
    DataSource ds = (DataSource) envContext.lookup("jdbc/dataSource");
    

    rather than

    SomeBean s = (SomeBean) initContext.lookup("java:comp/env/ejb/someBean");
    DataSource ds = (DataSource) initContext.lookup("java:comp/env/jdbc/dataSource");
    

    Relative paths instead of absolute paths. That’s what it’s used for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does a look-up like : Context envContext = (Context)initContext.lookup(java:comp/env); DataSource ds = (DataSource)envContext.lookup(jdbc/MyDatasource);
I have a Java applet that is meant to run only on Windows. (It
I am creating a Java web app that is meant for use by Facebook
I have a datasource set in my Jetty.xml file that looks like this: <New
What does public static void mean in Java? I'm in the process of learning.
What does the >> sign mean in Java? I had never seen it used
Does java has library exception class which means actually not an error, but good
Naive question about Java syntax. What does <T> T accept(ObjectVisitorEx<T> visitor); mean? What would
What is really meant when using Java Date utilities and something has been deprecated.
How to send mail from any mail id through java? i meant how can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.