• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

action attribute in JSP

 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I have a following line in a JSP. CrdServlet is subclass of a class named ControllerServlet and LoginHandler is a subclass of class named RequestHandler.

<form name="loginForm" method="post" action="CrdServlet/LoginHandler">

Can somebody tell me what above line means and how is it diffrent from
<form name="loginForm" method="post" action="LoginHandlerServlet"> ?? I want to know how you can specifiy 2 arguments in action attribute of form tag.

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anand Gondhiya:
I want to know how you can specifiy 2 arguments in action attribute of form tag.


You can't. You can only specify one URL.
 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your post.

but what does the following mean ?
<form name="loginForm" method="post" action="CrdServlet/LoginHandler">
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That greatly depends upon the mapping definitions in the deployment descriptor (web.xml). Care to give us a look at it?
 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. Here is web.xml. From what I understand , it maps CrdServlet/* (and thus CrdServlet/LoginHandler ) to CrdServlet , correct ??

<web-app id="WebApp">
<display-name>CRDWeb</display-name>
<servlet>
<servlet-name>CrdServlet</servlet-name>
<display-name>CrdServlet</display-name>
<servlet-class>com.jpm.crd.servlet.control.CrdServlet</servlet-class>
<init-param>
<param-name>crd.ini</param-name>
<param-value>/WEB-INF/crd.ini</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>CrdServlet</servlet-name>
<url-pattern>/CrdServlet/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
 
Chetan Chauhan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Anand, You have asked the difference between these two statements:

<form name="loginForm" method="post" action="CrdServlet/LoginHandlerServlet">

<form name="loginForm" method="post" action="LoginHandlerServlet">

1st statement specifies the complete path of LoginHandler. CrdServlet is also the name of the project, it seems from web.xml file.
While 2nd statement assumes that LoginHandler is in the current working directory.
If you write LoginHandler in some other directory say, xyz/LoginHandler then you have to specify its path as

xyz/LoginHandlerServlet OR
CrdServlet/xyz/LoginHandlerServlet

in the action attribute.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chetan Chauhan:

If you write LoginHandler in some other directory say, xyz/LoginHandler then you have to specify its path ...


No, that is all incorrect. The actual path in the folder structure has nothing to do with the mappings as defined in the web.xml.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anand Gondhiya:
From what I understand , it maps CrdServlet/* (and thus CrdServlet/LoginHandler ) to CrdServlet , correct ?


Yes, although you might run into difficulties omitting the leading /.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic