> On May 9, 2024, at 01:25, Mark Foley <mfo...@novatec-inc.com> wrote: > >> Does the JSP need to reference the "program" (servlet?) at all? > The program, as shown above didn'twork at all until I put that servlet > definition on WEB-INF/web.xml, so I suppose the answer is "yes". As to why, I > have not a clue.
A reading of the servlet spec might be in order here. Servlets (including JSPs) are selected based on the mapping of the <url-pattern> to the <servlet-name>. >> When you make a request, Tomcat determines which servlet in your application >> will service the request. If that's a JSP, then the JSP is invoked. A JSP >> just compiles to a servlet, just as if you had written a .java file with a >> class that "extends HttpServlet" or similar. >> >> It's not clear what "the program" is: JSP or servlet? Or something else? > The programs are written in Java/JSP and, yes, Tomcat "compiles" them to > .class -- probably servlets. No probably about it - JSPs are always compiled into servlets. “Program” is too generic a term to be used here - you need to be specific with what you’re talking about: servlets you coded and compiled, or JSPs that Tomcat turns into servlets. It’s hard to figure out exactly what you’re really talking about. > I think I may have figured this out. Here are my two servlet definitions in > WEB-INF/web.xml: > > <servlet> > <servlet-name>uploadfile</servlet-name> > <jsp-file>/schDistImportResults.jsp</jsp-file> > <multipart-config> > <location>/tmp</location> > <max-file-size>20848820</max-file-size> > <max-request-size>418018841</max-request-size> > <file-size-threshold>1048576</file-size-threshold> > </multipart-config> > </servlet> > <servlet-mapping> > <servlet-name>uploadfile</servlet-name> > <url-pattern>/schDistImportResults.jsp</url-pattern> > </servlet-mapping> > > <servlet> > <servlet-name>*upload1099*</servlet-name> I presume the asterisks are not actually present in your config. > <jsp-file>/1099R-Etrans.jsp</jsp-file> > <multipart-config> > <location>/tmp</location> > <max-file-size>20848820</max-file-size> > <max-request-size>418018841</max-request-size> > <file-size-threshold>1048576</file-size-threshold> > </multipart-config> > </servlet> > <servlet-mapping> > <servlet-name>*upload1099*</servlet-name> > <url-pattern>/1099R-Etrans.jsp</url-pattern> > </servlet-mapping> > > In the 2nd definition, Taking Chuck's hint, I changed the servlet-name to > "upload1099". That seemed to work for the 1099R-Etrans.jsp program, but I > haven't been able to test the schDistImportResults.jsp program yet to see if > I broke that one. Why these definitions are needed in web.xml and how all > that works under the hood is, as Chuck said, "magic”. It’s not magic at all - it’s how servlet selection works, as defined in the servlet spec. The “magic” was your expectation that servlets with the same name could co-exist. You need the web.xml entries because you have extra configuration items (the <multipart-config> settings) that aren’t part of the default JSP servlet definition. - Chuck