• Post Reply Bookmark Topic Watch Topic
  • New Topic

calling a servlet  RSS feed

 
Arvind Mahendra
Ranch Hand
Posts: 1162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought that If I had mapped my servlet in the web.xml as

I could just call it directly without using a slash or anything like that in my JSP like:
<form action="ProcessNewCust" method="get">

but It turned out my belief was wrong. To get this to work I had to do:
<form action="../ProcessNewCust" method="get">
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the page that contains the form?
Is it in the root directory of the app?
Is it in a JSP or a static HTML file?
 
Arvind Mahendra
Ranch Hand
Posts: 1162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:
Where is the page that contains the form?
Is it in the root directory of the app?
Is it in a JSP or a static HTML file?


It is its own JSP page that is in a folder called newCust.
I guess calling the servlet with a ../ takes me to the root of the web app?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does. the '../' symbol means 'parent directory'.

This is not the best way to build paths in a Servlet/JSP app.
See:
http://faq.javaranch.com/java/RelativeLinks
for a very complete and detail description of the contextPath and how best to add it to your URLs.
[ November 22, 2007: Message edited by: Ben Souther ]
 
Arvind Mahendra
Ranch Hand
Posts: 1162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:
It does. the '../' symbol means 'parent directory'.

This is not the best way to build paths in a Servlet/JSP app.
See:
http://faq.javaranch.com/java/RelativeLinks
for a very complete and detail description of the contextPath and how best to add it to your URLs.

[ November 22, 2007: Message edited by: Ben Souther ]


Hi Ben,
Thanks a lot for the link you directed me too. After reading it I am trying to build a link as depicted in that document, although I believe its discouraged but Id still like to try to use the domain name method.

In my header.html file. I tried doing something like this
<img src="http://localhost:8084/Abc_Autos/images/logo.jpg" >
where Abc_Autos is the name of my web app. But this technique doesn't work. I am using netbeans. I can see the images folder when I tab the 'files view' in netbeans. And I can also see the images folder and the image when I physically navigate to the directory.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!