Struts 1.2 validation question - java

I am validating my login form. I have created a validation.xml, added the plugin in struts-config.xml, created ApplicationResource.properties file etc. I have done all the necessary things for validation frame work, my application is also running without errors but it is not validating the data. I have rechecked many times. Please anyone tell me where should I check for probable errors.
Thanks

If as you say, the application is running without errors and your data is not validated, then I think that the validator plugin isn't picked up by your application. That could occur if your login form is not extending ValidatorForm but your plain ActionForm. Are you extending ValidatorForm?
Recheck your code against a Struts validator guide. Even if you already did that, there is still something you might have missed or misunderstood.
Have a colleague or friend look at it. Someone with a fresh clean perspective might notice something you missed because you stared to long at your own code.
If that is not possible you can always delete everything (that is to be read as: save current solution somewhere then get a clean copy from source control) and start from scratch. If then it works, you can compare with what you saved from your initial solution and spot the difference.

Related

Conflicts between two hooks modifying the same jsp file

I saw here some questions with the same topic as mine, but they are quite old. Is there maybe nowadays a working solution? Something that makes an automatic merge of the two hooks and wont destroy the default jsp?
For people who dont know what my problem is. When you deploy two hooks on the same .jsp file, the original jsp is being deleted. And im looking for a solution which makes an merge of the two hooks and the original wont be deleted.
Thanks
There's no concept of automatically merging two different JSPs - it would only work in few cases and leave others open to the same problem.
The code that Pankajkumar Kathiriya links in the comment (my blog article) solves this problem by denying the deployment of the second hook. You'll then have to merge/resolve the conflict yourself.
Some version of Liferay (maybe the latest 6.2 CE GA) implements it as well - the blog article links to the issue. Note that Liferay's own implementation doesn't give you the full logging information that my implementation gives you, but it works. There's also an extension that also includes duplicate overridden struts actions.

Is it possible to make Class.forName("") flexible?

before asking, please understand that my english is not good.
I'm using Class.forName(...) class in a servlet programming. when I access the servlet, I get a row of detailed controller information from Database indicating which controller to use.
This is Class.forName(...) I coded:
Class c = Class.forName(row.getControllerInfo);
c.newInstance();
This works fine, but there's a problem, i'm using Eclipse. The problem is that when I modified the Controller file, the changed contents were not applied to the server.,,.
Probably the easiest way is not to support dynamic loading. Much better to achieve something like dynamic update by supporting multiple servers. For development, you could get around redeploy delays by using JRebel (there might be others).
If you really do want dynamic loading of classes then the answer is "class loaders". I suggest having a look at those, and come back with any specific questions.
If I understood your problem true,
When you change any file of your project, you must deploy your project to server. If you use server from eclipse, republish may solve your problem.
have you tried clean - re-built and then deploying your application?

java service could not be initialized (debugging help)

I have a jar package that I wrote using netbeans. This package is called from other java file. The jar calls a webservice and is supposed to do something with it. Now everything works fine locally. I compiled the files and locally and uploaded them to the server and when I run it, I get the "Service could not be initialized".I am not sure how to debug this. I am pretty new to java. What is the best approach here to solve the issue?
I would start by implementing logging (I like log4J) in your project so you can get some better details of what is actually going wrong. This will be very useful not only now but in the future as things go wrong (they inevitably will) you will be able to solve them based on how good of a job you did logging what is happening in your application. Right now it sounds like an error is bubbling up and you're not getting much detail about it. Logging should help you determine not only what went wrong but where it happened and what the application was doing at the time.
Try this short introduction to log4j to get started.

How to test JSP TagExtraInfo?

I consistently have troubles getting my TagExtraInfo implementations to work properly. I have one implementation that works, and one that doesn't and I unable to see the difference between the two. And all the IDE's seem to have have "bugs/features" regarding this, which makes it hard to see where the problem actually is.
The relationship between a TagExtraInfo and a jsp tag should be reasonably well-defined, and I assuming I should be able to get some kind of compliance-testing software. Anyone know anything like this ?
You can use Jetty. That is a simple web container that can be started from your unit test. You can prepare a simple web.xml, test.jsp and monitor exceptions in order to see if everything works fine. There is an interesting article.

SWFUpload and Java: Session is lost

I am using SWFUpload to upload files to java servlet (spring framework). The problem is that the current web session is lost during file upload (it creates a new session). I read that it is a known bug and there are some workarounds somewhere but I can't find anything. Does anyone know how to make it work?
Thanks.
Have a look at this post on the SWFUpload forums. Adding ;jsessionid=XXX to the upload URL may work for you, or it may not; the exact cause of the problem appears unclear. Note that Flash uses the Wininet stack (same as IE), so if you are using a different browser you need to somehow get the session cookie (known to your browser) into the IE cookie.
Had this on the .NET platform as well. The problem is that the Flash Object runs in a different session context than your Java App (it's effectively treated like a new client). One way to get around all of this is to effectively have the object post any necessary information needed to commit the uploads back in the querystring.
The known bug you describe sounds like this one. If you have the time please sign up just to say "I have this problem too" so we can make it really clear to Adobe that it is affecting a lot of people.
It is hard to give an example of the best way to do it for your particular situation as I don't know much about spring.
That said, the usual way to work around it is to append a GET variable with the session to the upload url, then take that and manually set it to be the session on the server-side.
Here's another SO thread about this problem that has a good answer (unfortunately not specific to java+spring, but might give you a better idea).
Hopefully that's enough detail to get you off to a good start.

Categories

Resources