I am working with Java servlets, and I am new to it.
I was trying to write a jsp page wherein I will have a menu ( a list of links ).
In index.jsp I have the following code:
<ul>
<li> <a href="http://www.google.co.za">Home<a/> </li>
<li> <a href="login.jsp">login here<a/> </li>
</ul>
but when I click on the first link it works, but crushed when I click on the second link. login.jsp exists within the same dir as 'index.jsp'
how can I get login.jsp to work as well?
Put your login.jsp in /WEB-INF folder and then try.Do not put it under anything else
I managed to solve it. My JSP files were within WEB-INF. Just found out that what is in `WEB-INF is private and cannot be accessed dirrectly. So I put them on the root folder of the project ( in parallel to WEB-INF )
Related
So i have a simple nav bar that links to other pages on the website.
<ul class="navbar__list">
<li class="navbar__item">About</li>
<li class="navbar__item">Offerings</li>
<li class="navbar__item">Testimonials</li>
<li class="navbar__item">Contact</li>
<div class="navbar__contact">
Book a session
</div>
</ul>
Which all link to html files that also exist in the root directory (the same directory). Every time i try to use the link i am getting a response that says "Cannot GET /???" with ??? being the name of the html file i am trying to access.
I have played around with the paths, tried typing the name of the file explicitly, and have found that links to external sites work just fine, it's just internal pages that are causing problems.
The pages that i'm linking to do have content in them.
I'm hosting this locally using npm live-server, i'm not too experienced in it though and do wonder if there needs to be more configuration if i'm to use it to locally host several pages?
Thanks in advance
you need to write the full path to the file, not just its name
you missed .html after file name
If it is in the same directory, then write
href="about.html"
Essentially I am trying to link to my my GitHub Pages index.html file to the other files in the repository to make a multi page website.
The URL is correct, I have tried a bunch of ways and I am simply getting no where.
The main branch is called home, in it is the index.html file, as well as the other files, see below:
Main Branch is called home
The links inside the html file are:
<li class="masthead__menu-item">
Research
</li>
The file "research" is inside the home branch. I have tried naming it "research.html" I have tried deleteing the "home" from the above link so it directly links to research, see below:
<li class="masthead__menu-item">
Research
</li>
Nothing seems to work. What am I doing wrong?
After hours and hours of trying things, I finally got it to work:
<li class="masthead__menu-item">
Research
</li>
What I did was to get rid of the "home" and make the page an html file.
Thank you iamabdm and minwka!
Looking at the screenshot and the html you provided, I don't see any *.html extensions following the name of the files you're trying to link to.
For example: try renaming the file "research" to "research.html"
If the file is a html file then the problem is with the address of the URL i.e. https://xxx.github.io/research/ in Research.The last slash is causing the problem. Remove the last slash from the address, i.e. https://xxx.github.io/research and it will be Research.
I'm working on creating my first website and I've run into a problem. This is my file structure from my folder
Info.html
Blog.html
Testimonials.html
Contact.html
blog (folder)
---> blog-post.html (is inside blog folder)
The website has the same navigation on all of the main pages but the sub pages in the blog folder can only access other files within the blog folder. This makes it so that I cannot have Mywebsite.com/blog/blog-post.html link back to the info page as it's not in "blog" because it expects the link to come from the blog folder.
My question is, how can I keep the blog posts in a sub folder and still allow blog posts to contain links to the pages not within the blog folder?
Right now I'm structuring my navigation as such:
<nav><ul style="list-style-type:none">
<li>Info</li>
</nav>
I want to avoid duplicate content but i'd also like to have the blog/blog-post in the URL.
Is there a syntax or attribute that I should be using to fix my issue or have I made a mistake within structuring the files of my website?
use this "/" to refer to the root folder
Like this
<nav><ul style="list-style-type:none">
<li>Info</li>
</nav>
I my JSF view I display a list of links. When the user clicks on the list of links, two HTML files are loaded into a ui:include element from the folder on the server that the clicked link points to.
E.g. clicking the link:
http://localhost:7474/project/folder1
Loads the menu.html file from that folder into a ui:insert element as well as a file called cov.html into another ui:insert.
The menu.html looks like this:
<ul id="menu" xmlns="http://www.w3.org/1999/xhtml" >
<li class="menulink">
ONE
<ul>
<li class="menulink">
TWO
<ul>
<li class="menulink">
THREE
</li>
</ul>
</li>
</ul>
</li>
</ul>
Clicking on the link ONE should load the file
http://localhost:7474/project/folder1/files/one.html
into the ui:insert where previously the file cov.html had been loaded into (thus, replace the cov.html file).
So any file pointed to by one of those links in the menu.html should be loaded into the ui:insert.
When I click on one of the links now, it looks for the file:
http://localhost:7474/project/files/one.html
How can I get the value of the link that was clicked in my backing bean and load the correct file into the ui:insert?
Not an option for me would be to put the name of the folder into the link of the menu.html file, e.g. I cannot do this:
ONE
because the files get uploaded by users in a zip folder and I want them to be able to name that folder anything they like. So I cannot hardcord that folder name in the menu.html.
Do the a elements need to have an attribute that the backing bean can access or could I somehow incerpect the requestes URL and correct it?
What would be the best way to handle this?
I'm creating a series of web pages and I want them all to be linked together from a navigation bar, I currently have:
<li>XHTML & HTML</li>
However, if I need to export these files to another computer wouldn't the link be wrong and then not work?
How would I change these links so the file containing the HTML, CSS can be zipped up emailed to someone and it still work for them?
Use relative URLs.
<li>Home</li>
<li>About</li>
<li>Contact</li>
<li>Something</li>
The path is relative to the current file, home.html, about.html, and contact.html are all in the same folder, while page.html is in a subfolder named 'folder'.
Just use relative links - no need to include the file:///...... This will also mean if you upload it to the web or zip all the files together and send to someone else, it will still work - assuming of course you maintain the same folder structure and relative file locations.
For example I have a root folder with my index.html file which has the navigation links and a folder structure as below with firstpost.html and secondpost.html in the blog folder.
Web Project folder structure
index.html
Creation.html
blog/ (folder)
firstpost.html
secondpost.html
example links in index.html
<ul>
<li>
XHTML & HTML
</li>
<li>
First Post
</li>
<li>
Second Post
</li>
</ul>
check out this post that will give you a basic overview of the idea of absolute vs relative paths.