aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Using External style sheet to include background image in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Using External style sheet to include background image in JSP" Watch "Using External style sheet to include background image in JSP" New topic
Author

Using External style sheet to include background image in JSP

Romeo Ranjan
Ranch Hand

Joined: Feb 23, 2009
Posts: 92
Hi All,

I am trying to include background image in my JSP using external stylesheet.But when I run my tomcat server, the image is not being displayed. I use Spring MVC framework and eclipse IDE. This is my jsp code fragment



This is what I have in my est.css


My image are in the eclipse folder : com/myorg/projectname/web/image
My stylesheet is in the eclipse folder : com/myorg/projectname/web/styles

Thanks in advance.
Ms.Ranjan


SCJP 6.0
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

Where is the image file located in the WAR file? Where is the stylesheet located in the WAR file?


JBoss In Action
Romeo Ranjan
Ranch Hand

Joined: Feb 23, 2009
Posts: 92
I am new to web application. I am sorry if I am not answering your question but willing to learn..

As far as I know the WAR file is the used for the deployment of the web application. I use eclipse to run this dynamic project that I created. I didnt create any WAR file as such. Does it require to create WAR file to run the application in eclipse?? or am I missing something basic I am supposed to know??
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

Since you are new to web applications, my recommendation is to use a text editor and build your web application by hand. There are resources that will guide you through this, such as http://www.moreservlets.com/. That is a fairly old resource but it will teach you the basics, especially how a WAR file is laid out and how the parts of it work together. And how to deploy it to a servlet container.

The problem with relying on Eclipse when you are trying out a new Java technology is that when Eclipse screws up (and it does that fairly regularly), it you do not have the basic understanding about the technology, then you will be completely lost. Personally, I use Eclipse as a glorified text editor and use other mechanisms (Maven, Ant) to do my builds and deployment of web applications.
Romeo Ranjan
Ranch Hand

Joined: Feb 23, 2009
Posts: 92
Hi,

Thanks for your suggestions and your views. But I have a question this is how generally web application are being built, not many people use eclipse to develop dynamic webapplication? I am just weighing my option to learn maven and ant and start to build.

In my case the application will have to connect to Oracle database in future, in which case I have to setup the drivers if I start to do it by hand. But In eclipse just need to add jar files, which will save me from configuring the drivers and connecting to oracle. I am also using spring framework for this application.

Any other solution??
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

Here's a hint: the code you generate shouldn't have any references to Eclipse in it. If you think about it for a few seconds, you should realize the the application is going to be run on a different computer where Eclipse isn't even installed. So start by getting your hard-coded Eclipse references out of there.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

Yes lots of people use Eclipse (or NetBeans) to develop their web applications. But those people also understand how WAR files are laid out and how WAR files are deployed to the application servers of their choice. If you are unaware of these details then you will spent all of your time fighting Eclipse rather than getting anything done.

Also, you should learn both Ant and Maven. Depending on Eclipse to do your builds and deployment is not recommended. Yes you can use Eclipse to debug your app, but the "official" build should be done using Ant or Maven. Heck, even when I used Visual Studio to develop and debug C++ applications I still relied on make files for the official build. That is the only sane way to do things when there are multiple developers on a project andwhen you want to avoid the "gee, it works just fine on my machine" bug.
Romeo Ranjan
Ranch Hand

Joined: Feb 23, 2009
Posts: 92
Peter Johnson wrote:Where is the image file located in the WAR file? Where is the stylesheet located in the WAR file?


Hi,

I am using WAR file to deploy the application.
Romeo Ranjan
Ranch Hand

Joined: Feb 23, 2009
Posts: 92
Thanks Peter and Paul
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using External style sheet to include background image in JSP
 
Similar Threads
Multiple bundles broke my app(properties file)
Struts 2 Tiles
CSS not being recognized.. Struts application ..
jsp:include and c:import combination/nesting
c:import and header file question