• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

action attribute in JSP

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 /.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic