You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Franz-Josef Herpers <fj...@wir-age.de> on 2005/06/27 11:24:46 UTC

String as Parameterwith html:link

Hi,

I have a question concerning the Struts-HTML-Tag <html:link>. I want to 
generate a link to an action with one parameter which is a hardcoded 
String (not a value of a bean property which is present in a scope). And 
I don't want to use the url-Attribut but the action-Attribut to generate 
the link to the action. One example link could be: 
http://mydomain/setLocale.do?lang="de".

What I'm doing now is: create a HashMap with one entry and use the 
name-Attribut:

<jsp:useBean id="langParamMap" class="java.util.HashMap"/>
<c:set target="${langParamMap}" property="lang" value="de"/>
<html-el:link action="setLocale" name="langParamMap">
   lang
</html:el>

That works fine, but just out of curiosity: Is there really no 
possibility to just provide a string via an attribute of html:link which 
then is appended literally to the generated URL as a parameter. And if 
not is there a special reason for it?

Regards
Franz


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: String as Parameterwith html:link

Posted by Laurie Harper <la...@holoweb.net>.
http://struts.apache.org/userGuide/struts-html.html#link

You can use paramId, paramName and paramPropery to supply a single parameter w/out building a map, though that still requires the parameter value to be stored in a bean in some scope. There's no way to supply arbitrary values directly (i.e. not from a bean or map) unfortunately.

L.

Franz-Josef Herpers wrote:

> Hi,
> 
> I have a question concerning the Struts-HTML-Tag <html:link>. I want to 
> generate a link to an action with one parameter which is a hardcoded 
> String (not a value of a bean property which is present in a scope). And 
> I don't want to use the url-Attribut but the action-Attribut to generate 
> the link to the action. One example link could be: 
> http://mydomain/setLocale.do?lang="de".
> 
> What I'm doing now is: create a HashMap with one entry and use the 
> name-Attribut:
> 
> <jsp:useBean id="langParamMap" class="java.util.HashMap"/>
> <c:set target="${langParamMap}" property="lang" value="de"/>
> <html-el:link action="setLocale" name="langParamMap">
>   lang
> </html:el>
> 
> That works fine, but just out of curiosity: Is there really no 
> possibility to just provide a string via an attribute of html:link which 
> then is appended literally to the generated URL as a parameter. And if 
> not is there a special reason for it?
> 
> Regards
> Franz


-- 
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/~laurie/


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: caching staticJavascript.jsp?

Posted by Aymeric Alibert <ay...@neuf.fr>.
Found the answer to my own question. Just need to give the browser some
hints that it should cache the page. Something like:

- staticJavascript.jsp:
<%@ page language="java" contentType="application/x-javascript" %>
<%@ taglib uri = "http://struts.apache.org/tags-html-el" prefix =
"html"%>
<% response.setHeader("Cache-Control", "max-age=3600");%>
<html:javascript scriptLanguage="true" dynamicJavascript="false"
staticJavascript="true"/>


Aymeric.

-----Original Message-----
From: Aymeric Alibert [mailto:aymericalibert@neuf.fr] 
Sent: Monday, June 27, 2005 5:29 AM
To: 'Struts Users Mailing List'
Subject: caching staticJavascript.jsp?


I am building a Struts (1.2.7) application that client will access using
a slow connection (56K modem) and I am trying to limit the amount of
data downloaded from the server.
Since I am using the Validator, I would like to create an external
staticJavascript.jsp page that could be cached by the browser to hold
the javascript generated by the Validator.

Here is what I have:

- staticJavascript.jsp:
<%@ page language="java" contentType="application/x-javascript" %>
<%@ taglib uri = "http://struts.apache.org/tags-html-el" prefix =
"html"%>
<html:javascript scriptLanguage="true" dynamicJavascript="false"
staticJavascript="true"/>

- agencies.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page contentType = "text/html;charset=UTF-8" language = "java"%>
<%@ taglib uri = "http://struts.apache.org/tags-html-el" prefix =
"html"%>
<%@ taglib uri = "http://java.sun.com/jstl/core_rt" prefix = "c"%>
<%@ taglib uri = "http://java.sun.com/jstl/fmt_rt" prefix = "fmt"%>
<html:html locale="true">
  <head>
    <link rel="stylesheet" type="text/css" href="css/eacadmin.css">
    <script type="text/javascript" src="<html:rewrite
href='staticJavascript.jsp'/>" ></script>
  </head>
  <body>
...

The application is working fine, but the staticJavascript.jsp is
downloaded for each page (I tried both IE and FireFox). Any idea why the
browsers are not caching that page? 

Using a sniffer, here is the Request/Response I got each time:
Request:
GET /eacadmin/staticJavascript.jsp HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8)
Gecko/20050511 Firefox/1.0.4
Accept: */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Proxy-Connection: keep-alive
Referer: http://localhost:8080/eacadmin/agencies.do
Cookie: eacUserCookie=true; JSESSIONID=42975E280666F1E7455AA5EC6311BBD3


Response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/x-javascript;charset=ISO-8859-1
Date: Mon, 27 Jun 2005 10:11:29 GMT
Content-Length: 34166
.....

Any idea?
Thanks,

Aymeric.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


caching staticJavascript.jsp?

Posted by Aymeric Alibert <ay...@neuf.fr>.
I am building a Struts (1.2.7) application that client will access using
a slow connection (56K modem) and I am trying to limit the amount of
data downloaded from the server.
Since I am using the Validator, I would like to create an external
staticJavascript.jsp page that could be cached by the browser to hold
the javascript generated by the Validator.

Here is what I have:

- staticJavascript.jsp:
<%@ page language="java" contentType="application/x-javascript" %>
<%@ taglib uri = "http://struts.apache.org/tags-html-el" prefix =
"html"%>
<html:javascript scriptLanguage="true" dynamicJavascript="false"
staticJavascript="true"/>

- agencies.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page contentType = "text/html;charset=UTF-8" language = "java"%>
<%@ taglib uri = "http://struts.apache.org/tags-html-el" prefix =
"html"%>
<%@ taglib uri = "http://java.sun.com/jstl/core_rt" prefix = "c"%>
<%@ taglib uri = "http://java.sun.com/jstl/fmt_rt" prefix = "fmt"%>
<html:html locale="true">
  <head>
    <link rel="stylesheet" type="text/css" href="css/eacadmin.css">
    <script type="text/javascript" src="<html:rewrite
href='staticJavascript.jsp'/>" ></script>
  </head>
  <body>
...

The application is working fine, but the staticJavascript.jsp is
downloaded for each page (I tried both IE and FireFox). Any idea why the
browsers are not caching that page? 

Using a sniffer, here is the Request/Response I got each time:
Request:
GET /eacadmin/staticJavascript.jsp HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8)
Gecko/20050511 Firefox/1.0.4
Accept: */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Proxy-Connection: keep-alive
Referer: http://localhost:8080/eacadmin/agencies.do
Cookie: eacUserCookie=true; JSESSIONID=42975E280666F1E7455AA5EC6311BBD3


Response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/x-javascript;charset=ISO-8859-1
Date: Mon, 27 Jun 2005 10:11:29 GMT
Content-Length: 34166
.....

Any idea?
Thanks,

Aymeric.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org