• Post Reply Bookmark Topic Watch Topic
  • New Topic

getting parent URL from JSP page  RSS feed

 
Charles Chalifoux
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66152
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Sunny Bhandari
Ranch Hand
Posts: 448
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • 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....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!