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 8318331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:55:57+00:00 2026-06-08T21:55:57+00:00

I am implementing cron job schedular to send periodic email with attachment in a

  • 0

I am implementing cron job schedular to send periodic email with attachment in a web application.

Problem Description :
For creating a file (that will be attached with mail) in java code, I need session object to get absolute path of file.

For example :

request.getSession().getServletContext().getRealPath("/");

we use to get path.

So how can I implement/ get session object? Or is there any other way to get relative path of a file?

Note: I need to create attachmnet file in WebContent/MyFolder.

  • 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-08T21:55:59+00:00Added an answer on June 8, 2026 at 9:55 pm

    You cannot get HTTP session because there is no HTTP sessions in cron job. This job is asynchronous, it is running in its own thread and does not have any relationships with session. It will run even if no user connect to your server.

    So, your question is actually is how to get the path to file.

    And the answer is into your question. Pay attention on getServletContext(). You can extract servlet context from your servlet: servlet.getServletConfig().getServletContext(). So, if you have at least one servlet in your application you can put your servlet context (or better file path extracted from it) to static variable or to system property and then use it in your cron job.

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

Sidebar

Related Questions

Implementing a web service that uses Transport-level security with WCF over HTTP is pretty
I need help in implementing a simple cron job in GAE (python). According to
Implementing a custom membership provider, there are certain properties such as MinRequiredPasswordLength that only
Before implementing j_security_check using MySQL realm authentication in my web app. I had the
When implementing the Strategy Pattern, where does one put the code that determines which
Implementing Document-View pattern I faced the problem: standard generic collections and dictionaries ( List<T>
I have a multi part question for a php script file. I am creating
Whilst implementing my first MVVM application in WPF, I've been wondering about the pros
I'm implementing a memory cache for a table that looks like this (simplified): Item1
Implementing a Thread by providing a new class that extends Thread and overriding its

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.