KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need to use a single servlet with different URL pattern. I have given try in the tomcat server as below. but I want to know the real coding standard please help me out? String servletPath = request.getServletPath(); if("/HelloServletone".equalsIgnoreCase(servletPath)) { System.err.println("1?*"); ///logic move to controller one } if("/HelloServlettwo".equalsIgnoreCase(servletPath)) { System.err.println("2*"); ///logic move to controller two } web.xml <servlet> <servlet-name>Hello</servlet-name> <servlet-class>HelloWorld</servlet-class> </servlet> <servlet-mapping> <servlet-name>Hello</servlet-name> <url-pattern>/HelloServletone</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Hello</servlet-name> <url-pattern>/HelloServlettwo</url-pattern> </servlet-mapping> jsp1: <form method="post" action="HelloServletone"> //getting inputs and move to servlet <input type="submit" value="login " /> jsp2: <form method="post" action="HelloServlettwo"> //getting inputs and move to servlet
Tags (comma-separated)
Save Edits
Cancel