what values can a JSP form “action” take?

前端 未结 1 1252
無奈伤痛
無奈伤痛 2021-01-14 20:26

What can a JSP form action be? I have a Login.jsp page for the user to end the details. Can i give the servlet class in the form action?

here is the the servlet cod

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-14 20:54

    As per the specs , it can take any valid URI

    This attribute specifies a form processing agent. User agent behavior for a value other than an HTTP URI is undefined.

    Can i give the servlet class in the form action ?

    Yes if the servlet class name resolves to a valid URL mapped in the web.xml or else you will encounter a 404 .

    Let us consider your JSP is at the root of the application, then

    Now this will be resolved as protocol://servername:port/context/someServletName .Now somewhere you should have a mapping for /someServletName , either in web.xml or through annotation to a Servlet or JSP.

    
         someServletName
         packageName.servletName
    
    
         someServletName
         /someServletName
    
    

    0 讨论(0)
提交回复
热议问题