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.
Related
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.
Some Confusion about the source code of Tomcat
Some day before, I began to read the source code of the tomcat
First, the server starts from the main method in the org.apache.catalina.startup.BootStrap, but when I go into the code bootstrap.init(),
and I was confused by the following code.Like:
Just for easy to debug the tomcat, I change the code like this:
The code can still work. And in the Tomcat source code, there are many code block like this, For example,in org.apache.catalina.startup.BootStrap.start()
we can find the following code:
Still for easy to debug, I turn the code into:
>
The code still works fine.So I was confused, Here are my questions.
what's difference between the two kinds of code?
Why the coder of Tomcat do not write the code like what I write? what's the benefit?
If the Tomcat with my kind code works in a production environment, what will happen or nothing will happen?
1) what's difference between the two kinds of code?
The Tomcat code eliminates a static dependency on the Catalina class. In general, that has a couple of potential benefits:
It may allow you to substitute an alternative version of that class ... without changing the code. (But not here, because the FQN for the class is hard-wired.)
For some JVMs, it may result in deferred class loading which can give faster JVM startup. (I'm not sure if that is relevant here.)
In addition, the Tomcat code is explicitly creating a new classloader and loading the Catalina using that ... rather than the default one for the Bootstrap class. I'm not sure of the significance of that.
2) Why the coder of Tomcat do not write the code like what I write? what's the benefit?
Ask the coder. The (possible) benefits are as I described above, but it may have been done for some other reason ...
3) If the Tomcat with my kind code works in a production environment, what will happen or nothing will happen?
Probably nothing, though it might affect the classloader organization for Tomcat in some way that impacts on your webapps.
But if you are worried, don't change the code! There is no real need to change this ... based on why you said you are doing it. There's a saying:
"If it ain't broken, don't fix it."
I have a third party application which has lot of servlets and jsp. I wanted to debug that by putting breakpoints on my local jboss server. How do I know that, for a particular request, the request is being processed by particular java classes and jsp, so that I can put breakpoints in the right files? I am thinking of going through the code, before setting the breakpoints, to know where to put them. But I feel this is not an efficient way to do it (as it is a very big application). Can you please suggest if there is any better way to do this?
Thanks in advance.
The web.xml file contains servlet-mapping elements indicating which servlets are mapped to which URLs. So if you know the URL, you should easily find the corresponding servlet. Now you can read the servlet code to see which other classes are involved.
I think fastest way for debugging applications like this, is profiling application for specific usecase, in this way you can understand which classes used for this scenario and after finding classes, you can debug these classes.
for profiling application there are lots of tools.
commercial: Yourkit, JProfiler, JProbe
open source:VisualVM, Javacalltracer (create run-time sequence diagram)
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?
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.