Possible to refer to the contextPath in a Resource database url ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible to refer to the contextPath in a Resource database url ?

Rony G. Flatscher (Apache)
For a little nutshell example I would like to use SQLite as the JDBC driver includes the native code
for all the major operating systems already (this way a user does not really need to install SQLite
just place its JDBC driver in the lib directory).

The SQLite database (with sample data) should reside in the webapp itself, maybe in a subdirectory
named "data". Is it possible to define a "Resource" of type "javax.sql.DataSource" and use some
variable that would resolve the contextPath and that can be used in the "url" attribute? (The
Resource definition should be contained placed in the webapps' "META-INF/context.xml" Content element.)

There are samples that show how to use "${catalina.home}" as part of such a path. Is there a
variable that represents the contextPath of the webapp such that one can use that in the "url"
attribute?

---rony





---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Possible to refer to the contextPath in a Resource database url ?

markt
On 10/03/2021 19:44, Rony G. Flatscher (Apache) wrote:

> For a little nutshell example I would like to use SQLite as the JDBC driver includes the native code
> for all the major operating systems already (this way a user does not really need to install SQLite
> just place its JDBC driver in the lib directory).
>
> The SQLite database (with sample data) should reside in the webapp itself, maybe in a subdirectory
> named "data". Is it possible to define a "Resource" of type "javax.sql.DataSource" and use some
> variable that would resolve the contextPath and that can be used in the "url" attribute? (The
> Resource definition should be contained placed in the webapps' "META-INF/context.xml" Content element.)
>
> There are samples that show how to use "${catalina.home}" as part of such a path. Is there a
> variable that represents the contextPath of the webapp such that one can use that in the "url"
> attribute?

Not currently, no. It would be a little tricky to implement given how
${...} replacement currently works.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Possible to refer to the contextPath in a Resource database url ?

Rony G. Flatscher (Apache)
On 11.03.2021 12:14, Mark Thomas wrote:

> On 10/03/2021 19:44, Rony G. Flatscher (Apache) wrote:
>> For a little nutshell example I would like to use SQLite as the JDBC driver includes the native code
>> for all the major operating systems already (this way a user does not really need to install SQLite
>> just place its JDBC driver in the lib directory).
>>
>> The SQLite database (with sample data) should reside in the webapp itself, maybe in a subdirectory
>> named "data". Is it possible to define a "Resource" of type "javax.sql.DataSource" and use some
>> variable that would resolve the contextPath and that can be used in the "url" attribute? (The
>> Resource definition should be contained placed in the webapps' "META-INF/context.xml" Content
>> element.)
>>
>> There are samples that show how to use "${catalina.home}" as part of such a path. Is there a
>> variable that represents the contextPath of the webapp such that one can use that in the "url"
>> attribute?
>
> Not currently, no. It would be a little tricky to implement given how ${...} replacement currently
> works.

O.K., thank you very much!

---rony


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]