• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

getting parent URL from JSP page

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, i am new to jsp and i need to get the URL of the parent page in my JSP code since i need to check it to connect to the right DB. Right now the code is working fine since we call it from only one html page since the DB path is Hard coded but there is a problem when we want to call it from another webpage.

HTML page
containt
containt
....
Link to JSP
/HTML

In my code i then connect to the right DB to display Data in my page

Anyone could help me ?

Edit : i tried some method like getRequestURL() but it always return the servlet page (i think that's the right name not too sure though)

Thank you
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no concept of a "parent" page in JSP, so I'm not sure what you are asking for.

But, you should not be doing DB access in JSP pages. That should be done in Java controllers before the JSP is displayed. Perhaps you need to examine the structure of your application. Maybe this article can help get you started.
 
Charles Chalifoux
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the connection is made in java and every manipulation too.

Here an example of my code from one of my JSP page:



And i want to get the parent URL in my doGet in order to pass the previous URL to my ticket



All i want is not having to copy a second version of my program on the server for a simple DB link to change if the user use "page B" instead of "page A"

sorry my English isn't good. tell me if it do not make any sense
 
Ranch Hand
Posts: 448
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see the following line in your code:

System.out.println(request.getRequestURL())


Isn't that telling you the source from where the current was reached....
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic