• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help .... again .... please

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
I have asked the following question previously:
I have developed a servlet to download pdf books, this servlet takes the name of the book as the argument like :
<a href="http://localhost:8080/store/download?name=ebook.pdf">Download</a>
now, I want to give the servlet the following url pattern :
<url-pattern>/*.pdf</url-patten>
so I would write :
<a href="http://localhost:8080/store/ebook.pdf">
some ranchers told me that I should use the getPathInfo( ) method, but I don't know how !
so please give some tips and help.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, consider the following:

< servlet>
< servlet-name>PathInfoServlet</servlet-name>
< display-name>PathInfoServlet</display-name>
< servlet-class>com.ibm.demo.PathInfoServlet</servlet-class>
< /servlet>
< servlet-mapping>
< servlet-name>PathInfoServlet</servlet-name>
< url-pattern>/pdfs/*</url-pattern>
< /servlet-mapping>

Now, use a servlet that has the following code:



If your URL is of the form http://localhost:9080/MyContextRoot/pdfs/hello.pdf

This Servlet will print out "The path info is /hello.pdf".

Does this help?

Kyle

P.S. The reason why using just /*.pdf as the mapping won't work (I think) is that the servlet engine can't match the URL without more of an identifier in the URL -- it couldn't recognize that it was this particular servlet you wanted.
 
Nitin Mehhta
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your request will work if you change the url-mapping from /*.pdf to *.pdf ; Also in yout action you write the name of the book you want to read. So if you want to read a book ABC.pdf then in the action mention this name. Althrough the above mentioned solution will also work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!