Help coderanch get a
new server
by contributing to the fundraiser

John Paul Hoey

Ranch Hand
+ Follow
since Apr 15, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by John Paul Hoey

Its now working - but in Chrome and not Edge.

It seems to be browser related.

Strange that since I updated the app to run on Tomcat 10 and moved to a DataSourceRealm, Edge has stopped working.

PS  I've also just noticed I have posted this in the wrong section as it should probably be under security - apologies. Feel free to move if required.
Hi,

I recently upgraded a working web application which utilises JDBCRealm to Tomcat 10 however it stopped working. Further investigations found that JDBCRealm is now deprecated with Tomcat 10 therefore I have implemented DataSourceRealm.

The connection to the database using DataSourceRealm appears to be fine.

Now, however, when I attempt to log into the application using form authentication I am getting a server 408 response. Strangely, when I enter invalid credentials the invalid credentials page is being displayed.

I have performed a quick Google for a solution however the answers that I find don't seem to fix the issue.

I'm not sure why changing from JDBCRealm to DataSourceRealm would cause this issue however I'm hoping developers with more knowledge and experience than myself may be able to help me.

For info, here are the resource and realm tags from my context.xml file:



And here is my web.xml file:



I have left the server.xml file as default.

If you would like me to submit any more code then please let me know. Thanks
Just a quick update to inform anyone who may be interested that I managed to get my code to work. There where two issues:

1) The reference transforms were being added to the arraylist in the incorrect order, the ordering has to be the other way around as follows:



2) The white space between the elements of the XML that was being loaded by my code had to be removed. I did this using the following code:



Once I had performed the above, the digital signatures included within my XML worked as expected.

Just to add, I used the following code to also verify my digital signatures worked:



Hopefully the above may help someone in the future.
7 years ago
We have an unsupported application at my place of work which digitally signs XML messages using a certificate from a keystore that we want to replace. Im attempting to write a replacement application using Java however when I sign the XML, the generated digital signatures between both the existing application and my Java code are different. As the existing application obviously works Im not sure what is wrong with my Java code.

The digital signatures generated between both the existing application and my Java code are exactly the same except from the digest value and the signature value.

Here is the digital signature that is generated:



Here is the code that I use to generate the digital signature:



Can someone more experienced than me please take a look over my code to ensure that it looks OK and im not missing anything obvious? Also, any other troubleshooting tips that can be offered would be greatly appreciated. Thanks
7 years ago
Hi Tsuji,

It was indeed what you suggested. I downloaded and added the most recent .jars as you suggested and it worked as expected.

Thanks again for taking the time out to help me which is really appreciated.
I have the following XML:



And I want to remove the duplicate records from the XML that contain the same <TITLE> and <ARTIST> elements so that I end up with the following XML output:



The expected output works when I use the following stylesheet on the XML and transform it using XML Spy:



However when I pass this transformation to my Java code, the duplicates are removed however the last record within my XML is also removed. I have tried this with different XML files and it always removes the duplicates along with the last record - I have no idea why the last record is also being removed.

My Java code is as follows:



Has anyone got any idea as to why when I transform the XML using XMLSpy it works but when I transform the XML using my Java code the last record is being removed?

Thanks in advance
Hi,

I have a problem that I'm hoping someone may be able to help me with.

I want to load a public key (.cer file) into a keystore and then use this key to encrypt some data.

The key appears to be loaded into the keystore correctly because I can view its contents using the keystore.getCertificate(alias) method.

However, when I then attempt to use this key to encrypt a piece of data, I get the following error displayed:

Exception in thread "main" java.security.InvalidKeyException: Unsupported key type: null
at sun.security.mscapi.RSACipher.engineGetKeySize(RSACipher.java:404)


Here is my code:



I am not sure why I am getting this error therefore if someone could provide some input or guidance with this matter then that would be greatly appreciated.

Regards
8 years ago
Hi Bear,

Thanks for your response.

Hogwash. Beans are used extensively in web apps, especially in communicating between the servlet controllers and JSPs.



Yeah I was getting confused here. What I was actually meaning was in relation to the statement:

Do NOT use <jsp:useBean> if you're already using a servlet to process the model. It will only lead to confusion and maintenance trouble because the <jsp:useBean> follows a different level of MVC approach than when you're using servlets. It's either servlets or <jsp:useBean>, not both



Which it states at the bottom of the following link:

Stack Overflow - Servlets

This now makes sense to me.

Thanks again.
10 years ago
JSP
Hi K. Tsang,

I decided to go with session scope however can I ask what is the preferred way to store data between JSP and Servlets? Is it to use JavaBeans or to use Session scope? Is there a benefit to one over the other? Or is it subjective?

Thanks in advance
10 years ago
JSP
Hi All,

I 'think' I have figured out my question therefore I am marking this as resolved.

Cheers
10 years ago
JSP
Hi All,

[I have edited my initial question to this shorter one]

Basically, whats the best way to retain form data between multiple JSPs without using a submit button?

Essentially, when a user selects a value from a drop down list on one of the JSPs which populated multiple entries within a form, I want this selected data to be 'retained' between different JSPs until such time the user is happy with what they have selected. At which point the user can opt to 'submit' their selections from one of the JSPs - this is the only page to contain a submit button.

Is JavaBeans the way to go? I recently read that using JavaBeans with Servlets doesnt really conform to the correct standard. Ideally, if someone could advise if this is possible by only using JSTL along with session scope variables then that would be appreciated.

Hopefully my questions make sense however if not then please dont hesitate to let me know

Thanks in Advance

John Paul
10 years ago
JSP
Hi Bear,

Thanks for your responses.

The reason why im using Glassfish is because this is what was used during my Java module at the Open University. However after doing some Googling it seems Tomcat is the most popular.

Hopefully someone who uses Glassfish browses these forums but if not and I dont get any joy, I may give Tomcat a try :)

Thanks again

10 years ago
JSP
Hi All,

Firstly apologies for my ignorance but I have tried Googling this issue to no avail and most resolutions seem to relate more to JSTL and Tomcat rather than JSTL and Glassfish.

Anyway, I am currently in the process of learning JSP (JSLT & EL) using Netbeans 6.9.1 and Glassfish 3 and have encountered an issue that I cant seem to resolve.

When I add the following line into my JSP page:



I get the following error message displayed in Netbeans:

The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the JAR files deployed with this application

As ive already mentioned, most resolutions to this point to JSTL and Tomcat e.g. check your JSTL version and then download the relevant JSTL JAR files and put them in the WEB-INF/lib directory. However when I try and adopt this same approach with Glassfish, I dont seem to see a WEB-INF/lib directory, only a WEB-INF directory where I have put my .jsp files.

Nevertheless my questions are as follows:

1) As im using annotations, I havent created a web.xml file, which I assumed would be OK with the version of JEE im using. Does JSTL need a web.xml file to be present and configured to work correctly?
2) I cant seem to figure out how to locate the version of JSTL I am using within Glassfish. Can someone explain how I go about finding out what version of JSTL im using?
3) What is the directory path within Glassfish / Netbeans where I need to put my JSTL JAR files if I need to download them again?
4) Lastly, anyone got any idea how to solve this issue? :)

Any help with my questions & issues would be very much appreciated!

Regards

JP

10 years ago
JSP
Hi Steve / harshvardhan ojha,

Thanks very much for you feedback and yes, after taking some time out to understand this i think i have grasped the connection!

@Steve, your mention of the public Thread(Runnable target) constructor was the missing piece to my understanding, because basically, the reason why i can create Thread objects just by implementing the Runnable interface on my WhereAmI class is all down to that constructor; So by using that constructor, it needs something that IS-A Runnable, which in this case, is the place1 object!

Finally!

Thanks Guys, ive been trying to figure this out since Friday (should have came here first but i do like to try and figure things out myself )

Ill assume this same approach can be applied to other implementations of interfaces?

Thanks again

John Paul
11 years ago
Hi Steve,

Thanks very much for your quick response!

Ill take some time out to read and digest your feedback and the link you provided and if i have any more questions ill certainly come back

Thanks again

John Paul
11 years ago