Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [JSP] domande molto semplici su JSP, JSPF e JSTL

    Sto tentando di far la mia prima pagina JSP (sto usando NetBeans)

    index.jsp:
    codice:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
    
    <jsp:include page="WEB-INF/jspf/header.jspf">
        <jsp:param name="title" value="Hello World" />
    </jsp:include>
    
    Hello World
        
    <jsp:include page="WEB-INF/jspf/footer.jspf" />
    header.jspf:
    codice:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title><%=request.getParameter("title")%></title>
        </head>
        <body>
    
        <h1><%=request.getParameter("title")%></h1>
    footer.jspf
    codice:
        </body>
    </html>
    Tre domande:
    1) come faccio a buttar fuori in output nel .jspf i parametri che ho passato via jsparam dal .jsp ?

    2) ho provato a metter <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> dentro il file header.jspf in modo tale da poter usare la JSTL, ma in pratica non me lo prende :| è possibile usare i tag JSTL in un file .jspf ?

    3) I comandi: <%@page contentType="text/html"%><%@page pageEncoding="UTF-8"%> li devo mettere in ogni file .jsp o è sufficiente che li metto header.jspf che viene poi richiamato da tutti i file .jsp ?

    Grazie!
    A ship is waiting for us at the dock,
    America has trouble to be stopped.
    We must stop terrorism in that land,
    Or freedom will start sliping thru our hands.

  2. #2
    Utente di HTML.it L'avatar di nether
    Registrato dal
    Dec 2006
    Messaggi
    376
    1) come faccio a buttar fuori in output nel .jspf i parametri che ho passato via jsparam dal .jsp ?
    codice:
    <c:out value="${param.title}"/>
    2) ho provato a metter <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> dentro il file header.jspf in modo tale da poter usare la JSTL, ma in pratica non me lo prende :| è possibile usare i tag JSTL in un file .jspf ?
    deve funzionare per forza, io lo uso e non ho nessun problema.
    3) I comandi: <%@page contentType="text/html"%><%@page pageEncoding="UTF-8"%> li devo mettere in ogni file .jsp o è sufficiente che li metto header.jspf che viene poi richiamato da tutti i file .jsp ?
    bastano solo nel jspf che includi in tutte le pagine.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.