简体   繁体   中英

Accessing WAR file from outside

We have static HTML files which are outside of the WAR file. The files are "index.html", "about_us.html", "news.html". Lets say our war file name is "MyWarProject". Right now we launch the tomcat and directly access the WAR file using

localhost:8080/MyWarProject/

After we host it, the lcoalhost part will be replaced by a domain name.

But what we actually need is that user first access the "index.html", after that he click on "SIGN-UP" button to access the WAR file. How can I do this?

Actually, WAR files get unzipped inside the webapps folder and we can simply deal with HTML files after that. If the HTML is not highly affecting the rest, we can even add/remove them without issue.

How's about host the HTML files in another context (eg, localhost:8080/HTMLProject/) and you can have a link in the index.html to the "MyWarProject"

For that, you just have to create a new folder inside Tomcat's webapps for HTMLProject

You can navigate to the signup page by redirect the user via javascript. Example code below. Provide a button to the user on index.html on click the flow hits the signup page

index.html

<!DOCTYPE html>
<html>
<head>
<script>
function moveToSignUp() {
    window.location.assign("http://yourdomain/signup.jsp")
}
</script>
</head>
<body>

<input type="button" value="Move to SignUp" onclick="moveToSignUp()">

</body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM