Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to load CSS

 
an bo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i m having some problem with my struts application. I am tring do a forward from action class to some jsp page. When i do so the jsp loads but without the CSS formatting . But when i give the complete path of that jsp, everything loads properly. Please help.
 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi anup, welcome to javaranch.

Can you give a little code for your action, the struts configuration and the locations of your JSP and CSS files for us to be able to solve your problem better...
 
an bo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit,

Here's the code and all....

Code in Action Class(UserRegAction.java):
return mapping.findForward("success");

Struts-config:
<action input="/pages/loginform.jsp" name="UserRegForm" path="/register"
scope="request" type="com.blog.controller.action.UserRegAction">
<forward name="success" path="/pages/welcomelogin.jsp"/>
<forward name="failure" path="/pages/failure.jsp"/>
</action>


Code in Welcomepage.jsp:
<link rel="stylesheet" href="../assets/css/style.css" type="text/css" media="all" />

Locations:
loginform.jsp - Webcontent/pages/loginform.jsp
Welcomepage.jsp - Webcontent/pages/Welcomepage.jsp
style.scc - Webcontent/assets/css/style.css

Thanks
-Anup
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for test purpose, do

Just replace the "Application_Name" with the context OR name of your web app, and re run.
 
an bo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Sagar : No Success.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to play around with it,
Try
 
an bo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Sagar,
Following worked.

<link rel="stylesheet" href="../App/assets/css/style.css" type="text/css" media="all" />

Thanks a bunch, Sir.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome, and please don't called "Sir"
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general when creating links inside an app you'll want to use the <html:rewrite> (Struts 1), <s:url> (Struts 2), or <c:url> (JSTL) to create the links. This way you decouple your JSP from the deployment environment.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic