Miko
Miko

Reputation: 2633

How to get the base url in jsp?

Im creating a simple project by using jsp and servlet. I want to link the css in my jsp file. So any one can tell me the way to do this??

Upvotes: 0

Views: 1774

Answers (2)

Bozho
Bozho

Reputation: 597362

Try:

<c:url var="baseUri" value="/" />

Note that this will give you a relative url to the context.

Upvotes: 0

weekens
weekens

Reputation: 8292

You just need to do:

<link rel="stylesheet" type="text/css" href="css/style.css"/>

provided that you have style.css file in folder "css" near your .jsp file. You don't need to know the base URL for that, this will work with any base URL that leads to your .jsp file.

Upvotes: 3

Related Questions