Mark,
On 5/3/24 12:16, Mark Foley wrote:
On 4/23/24 18:44, Chuck Caldarale wrote:
<servlet>
<servlet-name>uploadfile</servlet-name>
<snip/>
</servlet>
<servlet-mapping>
<servlet-name>uploadfile</servlet-name>
<url-pattern>/schDistImportResults.jsp</url-pattern>
</servlet-mapping>
The first servlet is named “uploadfile”.
On Apr 23, 2024, at 12:42, Mark Foley<mfo...@novatec-inc.com> wrote:
Now I need to add another program to the system that does file
uploads. I
created another <server> definition in WEB-INF/web.xml following the
original:
<servlet>
<servlet-name>uploadfile</servlet-name>
<snip/>
</servlet>
<servlet-mapping>
<servlet-name>uploadfile</servlet-name>
<url-pattern>/1099R-Etrans.jsp</url-pattern>
</servlet-mapping>
This second servlet is also named “uploadfile”.
That didn't work so well. Now, any and all programs using the
fileupload
function launches this 2nd program 1099R-Etrans.jsp. It appears that
this
second <servlet> definition replaces the first.
You gave them the same names, so the second one wins...
What magic were you expecting to differentiate between the two?
- Chuck
I can easily change the name of the second servlet, but how would the
respective jsp programs (schDistImportResults.jsp, 1099R-Etrans.jsp)
specify one or the other? The programs do:
String contentType = request.getContentType();
if (contentType.startsWith("multipart/form-data;"))
{
Part fileUpload = request.getPart("taxResults"); // for
schDistImportResults.jsp
// or
Part fileUpload = request.getPart("vendor1099-MISC"); // for
1099R-Etrans.jsp
InputStream inFile = fileUpload.getInputStream();
:
}
That's it. There is nothing in the program that specifies a servlet
name. My initial servlet definition (for schDistImportResults.jsp) was
based on the XML suggestion from Christopher Schultz back in November,
2023. Since only the one jsp program was involved, there was no
discussion of how to specify more than one program in web.xml.
So, I can (and will) give the servlets different names in web.xml, but
how does the jsp program select the one for its use?
Does the JSP need to reference the "program" (servlet?) at all? 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?
It's also not clear how "the program" would or should reference a
servlet name.
Maybe you can explain (again)?
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org