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?

Thanks --Mark

Reply via email to