• 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

Call servlet from very first JSP

 
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Could you please tell me how to call a servlet from the very first jsp e.g. index.jsp

I need to know what to write in the action parameter of the form tag.

e.g.
does action parameter contain the actual name of the servlet class or something else ?

Also is there anything I need to change in the <url-pattern> tag ?



Please advise.">
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First:
Wrong, wrong, wrong!

This will make every request route to your servlet. Every request. Every! Is that what you want?

Second, once you have a valid mapping, the action URL should be the context path followed by the mapping pattern.

The context path can be obtained via the EL expression ${pageContext.request.contextPath}
 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Lucas,

I guess even /* will do in <url-pattern>, am I right ?

 
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

pramod talekar wrote:I guess even /* will do in <url-pattern>, am I right ?


Did you read my reply? If you plan to ignore them, just let me know.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear, take it easy. Some users want to get straightforward reply :).

pramod, just use it as I showed you :).
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear,

Thanks for your help. Please ignore it.

Lucas, you rock !!!
 
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

Lucas Smith wrote:Bear, take it easy. Some users want to get straightforward reply :).


And what part of my reply was not straightforward?

Mapping /* will cause all requests to map to the servlet. What is not clear about that?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Everything was crystal clear but pramod expected to get modified piece of his code, I guess :).
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NotACodeMill

It'd be more instructive to help him work out proper URL mapping than just hand him the code.
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right Bear.
In my index.jsp , I have just one button, hence I asked for /*.
All I needed was just the action tag setup.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear, I can't agree with you more:
"Give a man a fish and you feed him for a day.Teach a man to fish and you feed him for a life time."

But sometimes, someone wants to get a quick response.
 
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right Lucas.
I'm aware of the code, unfortunately forgot the action parameter setting.
Good night.
 
Ranch Hand
Posts: 49
Hibernate Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pramod talekar wrote:Hi,

Could you please tell me how to call a servlet from the very first jsp e.g. index.jsp

I need to know what to write in the action parameter of the form tag.

e.g.
does action parameter contain the actual name of the servlet class or something else ?

Also is there anything I need to change in the <url-pattern> tag ?



Please advise.">



specify the servlet name in action
<form method="get" action="test">
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mariya Antony christopher wrote:specify the servlet name in action
<form method="get" action="test">


No. Its wrong..
Bear and Lucas, have already given an answer.
reply
    Bookmark Topic Watch Topic
  • New Topic