A link to go back one level in the folder hierarchy and go to the level below in another folder

Asked

Viewed 1,041 times

3

Hello.

The problem is this: inside the Webcontent folder I have the hotel folder and inside this hotel folder I have the arqivo cadastro_hotel.jsp.

In the Webcontent root, I have the menu folder and inside this folder, I have the menu_inicial.jsp file. I created a link, inside the menu_inicial.jsp to point to hotel/cadastro_hotel.jsp, but I can’t. I already used .. / and nothing.

<a href="../hotel/cadastro_hotel.jsp">Cadastrar hotel</a>  

I mean, I’m one level down from the root, I want to go back to the root, and so, down to the other folder. I can make the return to the root using .. / but I can’t get to the level below.

  • 1

    What is the full address of these two files? ex: www.exemplo.com/hotel/cadastro_hotel.jsp and www.exemplo.com/menu/menu_inicial.jsp? if that is so, you can use only the / and this is the ideal way to organize links: always start with / and keep adding from there. This is called absolute links, those others that have ../ are called relative and usually cause problems because they work on one page, but not on the other that is within a different structure.

  • @Michelle Akemi The links are: localhost:8080/sgh/hotel/cadastro_hotel.jsp In the menu: localhost:8080/sgh/menu/menu_inicial.jsp That is, inside the webContent folder you have the hotel folder and the menu folder. I want to find out how to go back and forth between these two folders with the links herf.

  • Then use /menu/menu_inicial.jsp and /hotel/cadastro_hotel.jsp at the links.

2 answers

1

I solved it this way:

<a href="../menu/menu_inicial.jsp"></a>

and for the hotel folder and the registration file.jsp, I did:

<a href="../hotel/cadastro_hotel.jsp"></a>

O'. /' back to the root folder, which in this case is webContent and then just put the path: /folder/file or if it is on the same level, folder put the file name: /file.jsp.

0

In the case of JEE, the browser "sees" your application from Webcontent. As you are using the tag 'a' (anchor) ends up generating a new outside request (JSP/Java), that is, it is not necessary to use the "../".

Just put a href="hotel/cadastro_hotel.jsp"

If you use Sponse.Sendredirect('path') or request.forward(), then you would have to consider the hierarchical structure of your project, since you would be making a request/redirect via JSP.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.