File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Call servlet from very first JSP

 
pramod talekar
Ranch Hand
Posts: 323
Eclipse IDE Java Opera
  • 0
  • Mark post as helpful
  • send pies
  • 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.">
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 1
  • Mark post as helpful
  • send pies
  • 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}
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


 
pramod talekar
Ranch Hand
Posts: 323
Eclipse IDE Java Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Lucas,

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

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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: 323
Eclipse IDE Java Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

Thanks for your help. Please ignore it.

Lucas, you rock !!!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everything was crystal clear but pramod expected to get modified piece of his code, I guess :).
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64186
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 1
  • Mark post as helpful
  • send pies
  • 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: 323
Eclipse IDE Java Opera
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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: 323
Eclipse IDE Java Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right Lucas.
I'm aware of the code, unfortunately forgot the action parameter setting.
Good night.
 
Mariya Antony christopher
Ranch Hand
Posts: 49
Hibernate Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • 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">
 
Prasad Krishnegowda
Ranch Hand
Posts: 665
4
Eclipse IDE Java Spring
  • 2
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic