Tomcat java servlet redirecting to wrong URL - eclipse

I have a login servlet that is supposed to send a redirect to a specified url but instead I seem to be getting sent to an older version. I am using Tomcat 7 in eclipse and thinking it must be somewhere in the meta data that is screwie.
response.sendRedirect("../xyz/home.jsp");
but instead of going to xyz/home.jsp I am going to xyz1/home.jsp.
I had an old project called xyz1 which I then did a refracter to change the name to xyz. Now it seems that the login servlet keeps referring to xyz1/home.jsp. My other links are fine since I am using href and relative paths. I did a search through the meta-data to see if there was any older references to xyz1 and there were so I changed them and I also did a search in the server configuration files which I had also fixed. Not sure what other options there are.
Thanks,
-Tommy
Also the debugger is kind of useless since it goes through .class files that cant be read ...

I renamed xyz to be xyz1 and then just made a blank project called xyz. Only moved my source files and let the metadata fill in itself. I also made a new server just to be safe.

Related

Keycloak CSS is not updating in browser

I am upgrading Keycloak from 9.x to 12.x in a development environment. I initially copied some custom themes forward, and found that the styling was badly broken (no surprise). I reviewed my FTL files, copied some of the core changes into my theme, and things are much better - just some minor issues to adjust.
Now the problem. I've made the changes to my login.css file, but those changes aren't showing up in the browser. It continues to fetch an old version of my custom CSS file.
What I have tried (multiple times for most of these):
Clear browser cache
Restart Keycloak
Check ownership/permissions of theme files
Restart entire server
Load CSS file directly
Load CSS file directly with meaningless parameter added (trying to bypass any possible middleman caching)
Confirm new version of Keycloak is the one running
Load page in other browsers
I've also now grepped the entire Keycloak directory for some of the CSS rules I've removed, and I can't find any copies of the "old" css file anywhere that might be getting referenced by accident.
Also, there are no messages in the Keycloak log when loading the CSS file.
I want to figure out how to get Keycloak to deliver the updated CSS to the browser.
Blind guess, so please don't blame me if it doesn't work. (question should include minimal reproducible example):
Edit /opt/jboss/keycloak/standalone/configuration/standalone-ha.xml and update it as follows:
<theme>
<staticMaxAge>-1</staticMaxAge>
<cacheThemes>false</cacheThemes>
<cacheTemplates>false</cacheTemplates>
...
</theme>
For me it worked when changed this file
standalone.xml
like below way
<cacheThemes>false</cacheThemes>
<cacheTemplates>false</cacheTemplates>
I think it is because I am using single instance mode instead cluster ha mode.
Apart from disabling cache, as described above, you can also adjust the theme resource URLs, breaking the client-side cache. It's a bit of a hack, but you can directly modify the resource tag portion of the URL by adjusting the database migration_model.id value.
references:
https://github.com/keycloak/keycloak/blob/main/model/jpa/src/main/java/org/keycloak/models/jpa/MigrationModelAdapter.java
https://medium.com/#hokumski/how-to-drop-keycloak-theme-cache-without-clearing-browser-data-aebb499ae83b
You must delete the path keycloak-server\standalone\tmp\kc-gzip-cache\sbgwq or otherelse folder... and test in a browser in incognit mode.

Maintaining (version + redirect) in S3

So, far in our application, the *.js files were served directly from apache. For example, this was a script include in a jsp page : /foo/v6565/my_script.js. The v6565 in the path is phony and an internal apache redirect, redirects /foo/v6565/my_script.js to /foo/my_script.js.
Whenever my_script.js is updated, v<xxxx> in the included jsp page (an internal tool does it based on the SVN revision of my_script) is updated - thus forcing the browser to fetch my_script.js again and not the cached version. I hope I am able to explain my current approach clearly.
[A different approach could have been to user /foo/my_script.js?v=5652. However, there was some caching issue (can't remember it) because of which the decision was taken to use /foo/v56564/ instead of adding version to the queryParam. I will dig into it, though]
Now, that we are moving all of our *.js files to an s3 bucket, I was wondering what would be a way of doing this?
The path from s3 bucket would look like : mybucket.aws.com/js/my_script.js. How to I insert the version tag + redirection for s3? Are there any other standard approaches used when resources are served from s3?
(I've read about page redirects on s3 resources but the redirects are to be written directly on the resources, which is not really applicable in my case)
Thanks.
I think cache busting with ?v=<hash> is pretty much standard now.
It has been disadvised, however that's a pretty old resource (though often cited) and I'm not sure if this is still true. Even your trusted StackOverflow is using it with SHA1, so I guess it's good enough for everybody now.

How to add RESTful type routes in Jekyll

The root of the site http://example.com correctly identifies index.html and renders it. In a similar manner, I want, http://example.com/foo to fetch foo.html present in the root of the directory. The site that uses this functionality is www.zachholman.com. I've seen his code in Github. But still I'm not able to find how it is done. Please help.
This feature is actually available in Jekyll. Just add the following line to your _config.yml:
permalink: pretty
This will enable links to posts and pages without .html extension, e.g.
/about/ instead of /about.html
/YYYY/MM/DD/my-first-post/ instead of YYYY-MM-DD-my-first-post.html
However, you lose the ability to customize permalinks... and the trailing slash is pretty ugly.
Edit: The trailing slash seems to be there by design
It's actually the server that needs adjusting, not jekyll. Be default, jekyll is going to produces files with .html extensions. There may be a way around that, but it's unlikely that you really want to do go that route. Instead, you need to let your web server know that you want those files served when a URL is called with the file's basename (and no extension).
If your site is served via an Apache web server you can enable the "MultiViews" option. In most cases, you can do that be creating an .htaccess file at your site root with the following line:
Options +MultiViews
With this option enabled, when Apache receives a request for:
http://example.com/foo
It will serve the file:
/foo.html
Note that the Apache server must be setup to allow the option to be set in the htaccess file. If not, you would need to do it in the Apache config file itself. If your site is hosted on another web server, you'll need to look for an equivalent setting.

Tool to reverse map JSP to URL?

Is there a tool to automate the task of finding out where a given JSP is used, by URL?
Ultimately, the question I need to answer is, What URL(s) do I need to call, to see the output of this JSP in my browser?
Finding out involves searching for the JSP name, then searching for any JSPs that include it (possibly through several levels), ending up with one or more servlets - then trawling through web.xml to get the mapping of URL to servlet.
Having spent this morning doing exactly that, looking for examples of deprecated tags in our project, it seems to me that a computer would be quicker, if not better, at this than I am. For my purposes, I can live with not getting every URL; I really need to see only one use of the file in question.
So, is there a tool to do this? My IDE is Eclipse, so if Eclipse or some plug-in can do this that would be my preferred option. The application is running on Tomcat 6.
Thanks,
Check the contents of web.xml; it contains this mapping.
[EDIT] If you want to remove a JSP, here is what you need to do:
Check for an entry in web.xml
Search for <jsp:include and <%#include in all *.jsp files
That's all the places where your JSP can be used. You don't have to check for redirects and such since for a redirect to work, the JSP must be listed in web.xml.
Why do you require any eclipse plugin?
How about a simple text search in eclipse, where you can do a file search, that is search a text in all required file patterns - as below
(source: dopefly.com)

Associating a custom preview URL with a .cfm file in ColdFusion Builder (Eclipse)

In my usual ColdFusion directory layout all files are accessed via a controller called r.cfm that uses an include to pull in the actual .cfm file, so a file called "salaries.cfm" would be invoked via http://servername.com/r.cfm?name=salaries
In Eclipse with the ColdFusion extensions I could set the file properties so the default url for salaries.cfm would be http://localhost/r.cfm?name=salaries - when I ran the debugger that url would launch, not http://localhost/salaries.cfm - how do I set that up in the ColdFusion Bulder beta, the debug configuration is always non editable per file.
I have played around with server prefixes but that does not seem to do it.
Thanks for any tips
I don't think this is currently possible in CFBuilder -- as you said, this setting is not per-file. You could put in an Enhancement Request, though, if you wanted: https://bugbase.adobe.com