• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Virtual path not working in url

 
amarkirt saroay
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I as trying a sample application as in HFJS book chapter 3.
I have a form.html which says action="SelectBeer.do"

and the web.xml mapping is like:
<servlet>

<servlet-name>CH3 Beer</servlet-name>
<servlet-class>com.example.web.SelectBeer<servlet-class>

</servlet>

<servlet-mapping>
<servlet-name>CH3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>


NOw this works fine when my form is submitted.
But I want to have a virtual URL in the DD as well as the URL in addressbar.I tried to change the DD and action with "/virtual/mydir/SelectBeer.do" at both the places ie. form.html and DD url-pattern,but it did not work.It gave 404 error.
How can I change the URl pattern to anything virtual and still call the s
ame servlet?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you calling a virtual URL ?
 
amarkirt saroay
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/virtual/mydir/ directories do not exist in my webapp structure,its just made up and appears in the URL pattern only.
 
Pawan Arora
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can call servlet with any virtual name by simply changing your url pattern value in DD as *.do
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic