IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Struts 1 Java Discussion :

JSP balise html:img.


Sujet :

Struts 1 Java

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    44
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 44
    Points : 34
    Points
    34
    Par défaut JSP balise html:img.
    Bonjour,
    j'ai un pb avec la balise html:img.
    Dans ma JSP lorsque j'utilise la balise avec <html:img src="jfreechart-49329.jpeg" border="0" /> j'ai l'affichage de mon image qui est OK
    Par contre dans ma JSP lorsque j'utilise la balise avec <html:img src="${graphe.src}" usemap="${graphe.useMap}" alt="Texte remplaçant image" je n'est RIEN qui s'affiche.
    Pourtant lorsque je fais un <c:out value="${graphe.src}" /> j'ai bien mes valeurs qui s'affichent
    Ci-joint le code de ma JSP et en dessous les resultats de l'affichage de la valeur de mes parametres

    Si qqu'un pouvait m'aider je le remercie car j'y suis depuis hier..et je suis au bout de l'impasse.
    Merci par avance

    JSP:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    <%@taglib uri="/struts-html" prefix="html"%>
    <%@taglib uri="/struts-logic" prefix="logic"%>
    <%@taglib uri="/jstl-c" prefix="c"%>
     
    <logic:present name="graphe">
    	</br>
    	<html:img src="${graphe.src}" usemap="${graphe.useMap}" alt="Texte remplaçant image"
    	 border="0"/>
    	<html:img src="jfreechart-49329.jpeg" border="0" />
    	<c:out value="${graphe.map}" />
    	</br>
    	<c:out value="${graphe.src}" />
    	</br>
    	<c:out value="${graphe.useMap}" />
    </logic:present>
    RESULTATS AFFICHAGE:

    <map id="jfreechart-57932.jpeg" name="jfreechart-57932.jpeg">
    <area shape="poly" coords="872,198,878,198,878,204,872,204,872,198,872,198" title="Series 1 juin-2006 805" alt=""/>
    <area shape="poly" coords="707,339,713,339,713,345,707,345,707,339,707,339" title="Series 1 mai-2006 732" alt=""/>
    <area shape="poly" coords="547,182,553,182,553,188,547,188,547,182,547,182" title="Series 1 avr.-2006 813" alt=""/>
    <area shape="poly" coords="382,471,388,471,388,477,382,477,382,471,382,471" title="Series 1 mars-2006 664" alt=""/> <area shape="poly" coords="233,46,239,46,239,52,233,52,233,46,233,46" title="Series 1 f鶲.-2006 883" alt=""/>
    <area shape="poly" coords="68,198,74,198,74,204,68,204,68,198,68,198" title="Series 1 janv.-2006 805" alt=""/> </map>

    monAppli/servlet/DisplayChart?filename=jfreechart-57932.jpeg

    #jfreechart-57932.jpeg

  2. #2
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    Si les EL ne sont pas interprétées dans les balises Struts, cela signifie que tu n'es pas en J2EE 1.4 (Servlet 2.4/JSP 2.0).

    Pour passer en J2EE 1.4, il faut d'abord s'assurer que la version du serveur d'application que tu utilises la supporte.

    Si c'est bien le cas, dans le web.xml, il faut remplacer ces deux lignes:
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    <!DOCTYPE web-app 
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
        "http://java.sun.com/dtd/web-app_2_3.dtd">
     
    <web-app>
    par celle-ci :
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    	version="2.4">
    et si tu utilises la JSTL, il faut passer en JSTL 1.1.

    Si par contre, la version de ton serveur d'application ne fonctionne qu'en J2EE 1.3, tu peux utiliser la tld struts-html-el.tld à la place de la tld struts-html.tld.

    Il faut donc copier la tld struts-html-el.tld sous WEB-INF, la déclarer dans une balise taglib du web.xml et ajouter la directive taglib qui pointe sur cette tld au début de la jsp :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <%@taglib uri="/struts-html-el" prefix="html-el"%>
    et modifier le tag html:img comme ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <html-el:img src="${graphe.src}" usemap="${graphe.useMap}" alt="Texte remplaçant image" border="0"/>

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    44
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 44
    Points : 34
    Points
    34
    Par défaut erreur sur les balises:<display-name> et <taglib>
    Bonjour,
    j'ai effectivement remplacé les lignes comme indique, mais du coup j'ai une erreur sur ces balises:<display-name> et <taglib>

    Ci-joint le message d'erreur sous Eclispse pour <taglib>
    Merci de ton aide!
    cvc-complex-type.2.4.a: Invalid content was found starting with element 'taglib'.
    One of '{"http://java.sun.com/xml/ns/j2ee":description, "http://java.sun.com/xml/
    ns/j2ee":display-name, "http://java.sun.com/xml/ns/j2ee":icon, "http://
    java.sun.com/xml/ns/j2ee":distributable, "http://java.sun.com/xml/ns/
    j2ee":context-param, "http://java.sun.com/xml/ns/j2ee":filter, "http://
    java.sun.com/xml/ns/j2ee":filter-mapping, "http://java.sun.com/xml/ns/
    j2ee":listener, "http://java.sun.com/xml/ns/j2ee":servlet, "http://java.sun.com/xml/
    ns/j2ee":servlet-mapping, "http://java.sun.com/xml/ns/j2ee":session-config,
    "http://java.sun.com/xml/ns/j2ee":mime-mapping, "http://java.sun.com/xml/ns/
    j2ee":welcome-file-list, "http://java.sun.com/xml/ns/j2ee":error-page, "http://
    java.sun.com/xml/ns/j2ee":jsp-config, "http://java.sun.com/xml/ns/j2ee":security-
    constraint, "http://java.sun.com/xml/ns/j2ee":login-config, "http://java.sun.com/
    xml/ns/j2ee":security-role, "http://java.sun.com/xml/ns/j2ee":env-entry, "http://
    java.sun.com/xml/ns/j2ee":ejb-ref, "http://java.sun.com/xml/ns/j2ee":ejb-local-
    ref, "http://java.sun.com/xml/ns/j2ee":service-ref, "http://java.sun.com/xml/ns/
    j2ee":resource-ref, "http://java.sun.com/xml/ns/j2ee":resource-env-ref, "http://
    java.sun.com/xml/ns/j2ee":message-destination-ref, "http://java.sun.com/xml/ns/
    j2ee":message-destination, "http://java.sun.com/xml/ns/j2ee":locale-encoding-
    mapping-list}' is expected.

  4. #4
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    Soit tu mets les balises taglib dans une balise <jsp-config>.

    Soit tu supprimes les balises taglib du web.xml et tu références les tld dans les directives taglib des jsp via leurs uri.

    Peux-tu préciser quel serveur d'application tu utilises et sa version ?

  5. #5
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    Et j'oubliais, quelle balise display-name pose problème ?

  6. #6
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    44
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 44
    Points : 34
    Points
    34
    Par défaut serveur apache-tomcat-6.0.9
    precision: le fichier jFreeChart est bien cree dans temp

  7. #7
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    Ok, avec une version 6 de Tomcat, tu peux travailler en J2EE 1.4.

    Tu as corrigé ton web.xml ?
    Si tu n'y arrives pas, montre le code du web.xml en entier ?

    Et peux-tu préciser aussi la version de Struts que tu utilises ?

  8. #8
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    44
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 44
    Points : 34
    Points
    34
    Par défaut jakarta-struts-1.2
    Dans mon fichier STRUTS.XML j'ai ceci concernant ma JSP

    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    <!-- JFreeChart -->
    <action path="/chartAction" 
      type="com.cls.struts.action.ChartAction" input="/jsp/index.jsp">
      <forward name="success" path="/jsp/graphe.jsp" />
    </action>
    Le code Java de l'action et la classe Graphe sont ceux de l'exemple
    Remarque: Pas de BEAN utilisé

    Merci pour ton aide et ta disponiblite

  9. #9
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    Non, je parlais du web.xml.
    As-tu corrigé toutes les erreurs du web.xml ?

  10. #10
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    44
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 44
    Points : 34
    Points
    34
    Par défaut c'est pareil!
    j'ai modifie le web.xml, et ajoute la balise <jsp-config> et j'ai les memes pb a l'execution:

    seule l'image <html:img src="jfreechart-49329.jpeg" border="0" /> s'affiche,

    l'image <html:img src="${graphe.src}" usemap="${graphe.useMap}"
    alt="Texte remplaçant image" border="0" /> ne s'affiche pas

    angoisse...

  11. #11
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    44
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 44
    Points : 34
    Points
    34
    Par défaut ci-joint le web.xml
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    	version="2.4">
    	<!-- Déscripteur de déploiement -->
     
    	<display-name>Suivi Exploitation Argos</display-name>
     
    	<!-- Déclaration des servlets -->
    	<!-- com.cls.struts.action.SuiviExploitArgosController -->
    	<!-- org.apache.struts.action.ActionServlet -->
    	<servlet>
    		<servlet-name>action</servlet-name>
    		<servlet-class>
    			com.cls.struts.action.SuiviExploitArgosController
    		</servlet-class>
    		<init-param>
    			<param-name>config</param-name>
    			<param-value>/WEB-INF/struts-config.xml</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	<servlet>
    		<servlet-name>res</servlet-name>
    		<servlet-class>
    			com.cc.framework.resource.ResourceServlet
    		</servlet-class>
    	</servlet>
    	<servlet>
    		<servlet-name>action_tmp</servlet-name>
    		<servlet-class>
    			org.apache.struts.action.ActionServlet
    		</servlet-class>
    		<init-param>
    			<param-name>config</param-name>
    			<param-value>/WEB-INF/struts-config.xml</param-value>
    		</init-param>
    		<init-param>
    			<param-name>debug</param-name>
    			<param-value>3</param-value>
    		</init-param>
    		<init-param>
    			<param-name>detail</param-name>
    			<param-value>3</param-value>
    		</init-param>
    		<load-on-startup>0</load-on-startup>
    	</servlet>
     
    	<!-- Standard Servlet pour jfreechart -->
    	<servlet>
    		<servlet-name>DisplayChart</servlet-name>
    		<servlet-class>
    			org.jfree.chart.servlet.DisplayChart
    		</servlet-class>
    	</servlet>
     
    	<servlet-mapping>
    		<servlet-name>action</servlet-name>
    		<url-pattern>*.do</url-pattern>
    	</servlet-mapping>
    	<servlet-mapping>
    		<servlet-name>res</servlet-name>
    		<url-pattern>*.res</url-pattern>
    	</servlet-mapping>
     
     
    	<!-- Standard Action Servlet pour jfreechart -->
    	<servlet-mapping>
    		<servlet-name>DisplayChart</servlet-name>
    		<url-pattern>/servlet/DisplayChart</url-pattern>
    	</servlet-mapping>
    	<jsp-config>
     
    		<taglib>
    			<taglib-uri>/struts-bean</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/struts/struts-bean.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/struts-html</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/struts/struts-html.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/struts-logic</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/struts/struts-logic.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/struts-nested</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/struts/struts-nested.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/struts-template</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/struts/struts-template.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/struts-tiles</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/struts/struts-tiles.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/cc-base</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/cc/cc-base.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/cc-controls</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/cc/cc-controls.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/cc-forms</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/cc/cc-forms.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/cc-menu</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/cc/cc-menu.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/cc-security</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/cc/cc-security.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/cc-svg</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/cc/cc-svg.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/cc-template</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/cc/cc-template.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/cc-utility</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/cc/cc-utility.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/jstl-c</taglib-uri>
    			<taglib-location>
    				/WEB-INF/tlds/jstl/c-1_0.tld
    			</taglib-location>
    		</taglib>
    		<taglib>
    			<taglib-uri>/jstl-fn</taglib-uri>
    			<taglib-location>/WEB-INF/tlds/jstl/fn.tld</taglib-location>
    		</taglib>
    	</jsp-config>
    </web-app>

  12. #12
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    Et quand tu affiches le source de la JSP, les EL ne sont toujours pas interprétées ?

  13. #13
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    44
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 44
    Points : 34
    Points
    34
    Par défaut J2EE 1.4.
    Je suis en J2EE 1.4. tu m'avais dit que les balises EL etaient utiles seulement si j'etais en J2EE 1.3... ou j'ai mal compris!

  14. #14
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    Je ne te parle pas des balises html-el mais des EL.

    ceci : ${graphe.src}, ça s'appelle une EL (Expression Language).

    En J2EE 1.4, elle devrait être interprétée même dans un tag Struts.

    Dans la jsp, code exactement ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <%@taglib uri="/struts-html" prefix="html"%>
    <%@taglib uri="/struts-logic" prefix="logic"%>
     
    <logic:present name="graphe">
       <div align="center">
    	${graphe.map}
    	</br>
    	<html:img src="${graphe.src}" usemap="${graphe.useMap}" border="0"/>
       </div>
    </logic:present>

  15. #15
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    44
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 44
    Points : 34
    Points
    34
    Par défaut et ca marche!
    desole de t'avoir embete pour si peu..
    J'apprend a la dure et sur le tas... mais si tu as qq minutes pour me dire la difference avec mon code..ca m'aiderait.
    Merci beaucoup pour ton aide, et bon we.. ca detendra tout le monde!

  16. #16
    Expert éminent

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Points : 7 778
    Points
    7 778
    Par défaut
    Ce code :
    intègre la map du graphe dans la page (balise html map).

    et celui-ci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <html:img src="${graphe.src}" usemap="${graphe.useMap}" border="0"/>
    dans l'attribut src, tu lui précises où se trouve l'image à afficher (monAppli/servlet/DisplayChart?filename=jfreechart-57932.jpeg ) et dans l'attribut useMap, tu lui donnes la référence à l'id de la map (#jfreechart-57932.jpeg) que tu viens d'intégrer dans la page via l'EL ${graphe.map}.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 15/05/2014, 20h52
  2. Insertion image dans un JTextPane avec balise html img
    Par Invité dans le forum AWT/Swing
    Réponses: 2
    Dernier message: 10/01/2012, 16h04
  3. Réponses: 22
    Dernier message: 28/08/2011, 23h12
  4. JSP : Utilisation d'une itération dans une balise <html:option
    Par sandrine49 dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 18/05/2011, 11h29
  5. balise html depuis JSP
    Par Bobble dans le forum Servlets/JSP
    Réponses: 0
    Dernier message: 18/05/2011, 09h53

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo