Jump to content

Facing some issues accessing my Servlet App


rakesh73

Recommended Posts

Username: rakesh73

server: Tommy

 

I have deployed a new war file using cPanel. I am facing two issues described below:

 

1. The servlet path is not available securely. The servlets are accessible on http:// On trying to access by https:// I get a 404 error. I was expecting the servlets to be available on a secure path just like jsp files. This could cause security issues for example if I try to send login information to a servlet, I should be sending over a secured path.

 

2. I set some relative paths for static resources like javascript and css files using httpServletRequest.getContextPath().

My application url is <my-domain>/blog, but the  httpServletRequest.getContextPath() returns a contextPath /rakesh73_blog

 

This makes setting the relative paths very difficult. The httpServletRequest.getContextPath() should return contextPath "/blog" as visible in the last part of the application url.<my-domain>/blog

 

 

Thanks

 

Link to comment
Share on other sites

I've answered in your other topic and unsolved it for you. My response is copied below for reference:

 

For #1, we don't support HTTPS for Java by default because it uses a lot of resources and means your account would use up 2 Java slots instead of one if supported both HTTP and HTTPS. It can be enabled for you, but regular HTTP won't work anymore if you want us to do this.

 

For #2, this is a limitation of how we handle WAR files. It occurs because we deploy into a username prefixed folder. If we didn't, nobody else on the server would be able to have a WAR called "blog". We recommend naming your WAR file with the username_ in front of it (e.g username_blog) so the deployment path and the URL are the same. There is no fix other than to either rename the WAR, or develop your code to make the assumption that the username will appear in front when searching for its files.

 

Link to comment
Share on other sites

Redeployed the war with <username>_blog.war. The url is <my-domain>/blog and the contextPath is /<username>_blog.war

 

 The app is still not able to find the files and submit forms. The login form needs to submit to /rakesh73_blog/login, but that page is not found as the url is <my-domain>/blog

 

I tried setting all relative paths to /blog, but then faced cookies issue so reverted the changes.

 

 

Please let me know if there is any thing that will solve the cookie issue and the contextPath issue.

Link to comment
Share on other sites

I just discovered that after going to home page http://<my_domain> and then navigating to http://<my_domain>/rakesh73_blog I get the session to persist.

 

If I go to http://<my_domain>/rakesh73_blog disrectly, session does not hold across request.s. 

 

 

Please do not make the changes as described in above post. I need to do some more testing. I will post again If I need anything to change.

 

 

 

Thanks for your patience

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...