Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

Struts: Problem rewrite page for links and images

Hi!

I'm new to Struts, and I'm developing my first web application using Struts.  Actually I'm just following the guidelines of the tutorial that I have.

Currently I'm facing 2 problems:

1) Images:  According to my tutorial, you can use page rewrite when you use images in a tile.    
    So what I do is this:
    - in the head I define:
      <%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
      <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    - to put the image, I use:
      <img src="<html:rewrite page='/imgs/chimay01.bmp'/>">

    The problem is that the img doens't show.  I checked that the url and everything is correct,
    but apparently that ain't the problem.

2) Links:  When I click on them, they don't redirect.  You can hear the typical "click", but ...
    that's all.
    - I define them like this:
      <a href="html:rewrite page='/history.jsp'/>">History</a>

Now, the rewrite page works perfectly for the stylesheet when I use this:
<link rel="stylesheet" href="<html:rewrite page='/css/styles01.css'/>" type="text/css">

I read somewhere that, to use images and rewrite page, you should put the value $P in the pagePattern.  I guess that refers to the struts-config file, so what I did there was this:
<controller
       processorClass="org.apache.struts.tiles.TilesRequestProcessor"
       pagePattern="$P"/>

Any suggestions?

Thanks in advance

s5020847

     
0
s5020847
Asked:
s5020847
  • 2
1 Solution
 
fargoCommented:
Hi,

r u using Tiles? if not, there is no need to define the processor class. Moreover, why do u need the pagePattern? Any special reason for pagePattern? There is nothing like you need to use a special pagePattern for using rewrite tag.

remove the controller element and check it.

regards,
fargo




0
 
s5020847Author Commented:
Hi

Yes, I'm using tiles.  I'm not really sure what the page pattern does actually ... I just read somewhere that you need it for images that use rewrite page ... :o(

Anyway, I took the pagePattern away, but the problem is still the same ...
0
 
s5020847Author Commented:
I found it!  The thing is that you have to put the following line in the tile itself:

 <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>

s5020847
0
 
GranModCommented:
PAQed with points refunded (125)

GranMod
Community Support Moderator
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now