What I am attempting to is make it so I can call ${....} on it's (or
it's child classes) as a part of a template without having to call
pageContext.setAttribute(....) on it first

On Sat, Sep 9, 2023 at 7:50 AM Thomas Hoffmann (Speed4Trade GmbH)
<thomas.hoffm...@speed4trade.com.invalid> wrote:
>
> Hello,
>
> > -----Ursprüngliche Nachricht-----
> > Von: Aryeh Friedman <aryeh.fried...@gmail.com>
> > Gesendet: Samstag, 9. September 2023 12:57
> > An: Tomcat Users List <users@tomcat.apache.org>
> > Betreff: Re: page extends not working???
> >
> > Oops forgot to include the full log see below replaced inline
> >
> > On Sat, Sep 9, 2023 at 6:52 AM Aryeh Friedman
> > <aryeh.fried...@gmail.com> wrote:
> > >
> > > Every other jsp in my webapp (and other webapps on the same tomcat
> > > instance [9.0.75]) works and I am using a the default container but as
> > > curl/catalina.out show BasePage is *NEVER* being called (either the
> > > _jspService() or the getX()):
> > >
> >
> > src/java/dashboard/web/pages/BasePage.java
> > package dashboard.web.pages;
> >
> > import java.io.IOException;
> >
> > import javax.servlet.ServletException;
> > import javax.servlet.http.HttpServletRequest;
> > import javax.servlet.http.HttpServletResponse;
> > import javax.servlet.jsp.HttpJspPage;
> >
> > import org.apache.jasper.runtime.HttpJspBase;
> >
> > public class BasePage extends HttpJspBase {
> >     @Override
> >     public void _jspService(HttpServletRequest req,HttpServletResponse res)
> >         throws IOException,ServletException
> >     {
> >         System.out.println("Hello, world");    // where does this go
> > cataline.out?
> >     }
> >
> >     public int getX()
> >     {
> >         System.out.println("Hello, to the the framework from hell");
> >         return 123234;
> >     }
> >
> >     public static final long serialVersionUID=0L; } tlaitc-dashboard-
> > 1a1.C017@sarek1024% !cu curl http://sarek1024:8080/tlaitc-dashboard-1a1/
> > <!-- Copyright (C) 2023 TLAITC and contributors -->
> >
> > hi x is
> > tlaitc-dashboard-1a1.C017@sarek1024% sudo tail -10 /usr/local/apache-
> > tomcat-9.0/logs/catalina.out
> > 09-Sep-2023 06:29:58.770 INFO [Catalina-utility-2]
> > org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned
> > for TLDs yet contained no TLDs. Enable debug logging for this logger for a
> > complete list of JARs that were scanned but no TLDs were found in them.
> > Skipping unneeded JARs during scanning can improve startup time and JSP
> > compilation time.
> > 09-Sep-2023 06:29:58.771 INFO [Catalina-utility-2]
> > org.apache.catalina.startup.HostConfig.deployWAR Deployment of web
> > application archive [/usr/local/apache-tomcat-9.0/webapps/tlaitc-
> > dashboard-1a1.war] has finished in [69] ms
> > 09-Sep-2023 06:38:58.992 INFO [Catalina-utility-2]
> > org.apache.catalina.startup.HostConfig.undeploy Undeploying context
> > [/tlaitc-dashboard-1a1]
> > 09-Sep-2023 06:38:58.995 INFO [Catalina-utility-2]
> > org.apache.catalina.startup.HostConfig.deployWAR Deploying web
> > application archive [/usr/local/apache-tomcat-9.0/webapps/tlaitc-
> > dashboard-1a1.war]
> > 09-Sep-2023 06:38:59.081 INFO [Catalina-utility-2]
> > org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned
> > for TLDs yet contained no TLDs. Enable debug logging for this logger for a
> > complete list of JARs that were scanned but no TLDs were found in them.
> > Skipping unneeded JARs during scanning can improve startup time and JSP
> > compilation time.
> > 09-Sep-2023 06:38:59.082 INFO [Catalina-utility-2]
> > org.apache.catalina.startup.HostConfig.deployWAR Deployment of web
> > application archive [/usr/local/apache-tomcat-9.0/webapps/tlaitc-
> > dashboard-1a1.war] has finished in [87] ms
> > 09-Sep-2023 06:43:59.239 INFO [Catalina-utility-1]
> > org.apache.catalina.startup.HostConfig.undeploy Undeploying context
> > [/tlaitc-dashboard-1a1]
> > 09-Sep-2023 06:43:59.245 INFO [Catalina-utility-1]
> > org.apache.catalina.startup.HostConfig.deployWAR Deploying web
> > application archive [/usr/local/apache-tomcat-9.0/webapps/tlaitc-
> > dashboard-1a1.war]
> > 09-Sep-2023 06:43:59.331 INFO [Catalina-utility-1]
> > org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned
> > for TLDs yet contained no TLDs. Enable debug logging for this logger for a
> > complete list of JARs that were scanned but no TLDs were found in them.
> > Skipping unneeded JARs during scanning can improve startup time and JSP
> > compilation time.
> > 09-Sep-2023 06:43:59.332 INFO [Catalina-utility-1]
> > org.apache.catalina.startup.HostConfig.deployWAR Deployment of web
> > application archive [/usr/local/apache-tomcat-9.0/webapps/tlaitc-
> > dashboard-1a1.war] has finished in [87] ms tlaitc-dashboard-
> > 1a1.C017@sarek1024% cat src/www/WEB-INF/web.xml
> > <!-- src/www/WEB-INF/web.xml -->
> > <!-- Copyright (C) 2023 TLAITC and contributors --> <web-app>
> >     <servlet>
> >                 <servlet-name>spelling</servlet-name>
> >                 <servlet-class>
> >             dashboard.web.servlet.SpellingServlet
> >         </servlet-class>
> >         </servlet>
> >         <servlet-mapping>
> >                 <servlet-name>spelling</servlet-name>
> >                 <url-pattern>/servlet/spelling</url-pattern>
> >         </servlet-mapping>
> > </web-app>
> >
> >
> >
> > --
> > Aryeh M. Friedman, Lead Developer, http://www.PetiteCloud.org
> >
>
> I am not quite sure what you want to achieve. Why should the BasePage-Class 
> be called?
> The web.xml shows the class SpellingServlet and the source is from BasePage(?)
> Second, why do you derive from the class HttpJspBase and not using the 
> HttpServlet-Class?
>
> curl http://localhost:<port>/<app>/servlet/spelling
> should run the SpellingServlet
>
> Maybe you can give some more information about that.

What I am attempting to is make it so I can call ${....} on it's (or
it's child classes) as a part of a template without having to call
pageContext.setAttribute(....) on it first but still want to allow for
normal old JSP to be processed basically each page would be something
like this (backed out the changeset so typing from memory):

<%@page extends="dashboard.web.pages.BasePage"%>
<%@include file="[location of master template]"%>

As I test I replaced the include hi x is ${x} and got the output above.

Larger picture I am attempting to take the following template skeleton
and make it so there is zero in-line java but still treat it as a
normal old jsp page (no weird forwards from other servlets or
whatever) [btw this code works]:

<!-- Copyright (C) 2023 TLAITC and contributors -->
<%
    String url=request.getRequestURI();
    int split=url.indexOf("/",1);

    if(split<0)
        split=url.length();

    String relUrl=url.substring(split,url.length());
    String pageName="";

    if(relUrl.equals("/"))
        pageName="index";
    else
        pageName=relUrl;

    pageContext.setAttribute("relUrl","/content/"+pageName+"/main.jsp");
%>

<html>
<head>
    <%@include file="/widgets/scripts/scripts.jsp"%>
</head>
<body>
    <jsp:include page="${relUrl}"/>
</body>
</html>

>
> Greetings,
> Thomas
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org



-- 
Aryeh M. Friedman, Lead Developer, http://www.PetiteCloud.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to