• 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
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Passing URL in src attribute

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all ,
I have a static html page : decide.html"
which I invoke by the URL :

http://localhost:8080/happy/decide.html

OR

http://localhost:8080/sad/decide.html

In this static page ( decide.html ) I want to make a call to a servlet .

Here I am making use of code similar to this in decide.html :



Now my control is transferred to the servlet and I can execute code

However the problem is : How do I pass the URL in the src attribute to the servlet

I would like to dynamically pass either :
http://localhost:8080/happy/decide.html
OR
http://localhost:8080/sad/decide.html

based on which I would like the servlet to behave differently

Any help is appreciated
Thanks ,
-satish
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aside from the fact,that since they are different pages you can call 2 different servlets, you can add a parameter to your src url.
something like

You can get that currentUrl thing using javascript (at this case you need to use document.write to write script statement), or use JSP/Servlet API and don't forget to encode the url.
Than in a servlet you use request.getParameter("url") to get the value
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic