Not sure if it possible or not
Once a WebApp is running, is it possible to add a new JSP to the Webcontent folder, and assuming you know the name of newly added JSP make a requst for this new JSP?
Edit: Adding more details
We have a Java Batch application that will generate JSP files with embeded Java Scriplets e.g."<% Person.getName() %>". We want to be able to Run these JSP from within the web container to populate the javacode.
The only problem is that these JSP files are generated externally from the webapplication and we cannont restart the webapp everytime a new JSP is produced.
As a WebApp is running AFTER you deploy the project in the server, any change made while the WebApp is running won't affect the project until you deploy the project again.
I believe it's possible, but the question is too broad to give a meaningful answer.
One example of such behavior, is running Apache Tomcat server in debug mode in Eclipse, but that's a very special case.
Related
I am building a servlet app to run on tomcat server. However when i was not able to update the jsp page using:
request.setAttribute("operation", "op_name");
request.getRequestDispatcher("\WEB-INF\index.jsp").forward(request, response);
404 index.jsp not found comes.
I think that servlet and web elements like jsp are in different paths that's why it is going wrong. So do i need to make another project using maven structure like having src\main\java etc. or this structure is also fine? Also how to update the index.jsp using this structure?
Question: How can I get at runtime the filepath from where the server is loading the servlet class that was generated for a given JSP file? For instance, I have a JSP file research_form_manage.jsp that is accessible at a certain URL and I want to log the filepath for the generated __research_form_manage.java that is handling my request (it will be in a cache on the server probably).
Context: I have a web application deployed on WebLogic 12c (that I automatically deploy using JRebel from IntelliJ). Sometimes I get errors because the JSPs are loaded from some cache and are outdated. I manually cleared the cache locations I know (tmp\ and cache\ from under my_domain\server... and then restarted the server) but the file is still loaded from the cache.
I found this idea about how to locate where cached classes are loaded from and I would like to log the location of the jsp translated servlet using somthing like
...class.getProtectionDomain().getCodeSource().getLocation();
I found a way that seems to work, by adding in the JSP file this line:
<%= getClass().getProtectionDomain().getCodeSource().getLocation() %>
The class is in the domain\servers...\tmp folder that I deleted, so I don't know where the old version of the jsp was coming from.
This code does what I needed but it's not that nice because it means I have to modify the JSP and then remember to clean it before pushing. I was thinking initially to put a breakpoint somewhere and add a watch with an expression that would give this filepath based on the jsp file name.
So if anybody has a better way, please share.
I want to extend the users admin portlet that is located in the control panel. I hooked the jsp and wanted to use methods from the service builder that are in the same hook as the jsp.
The problem is that the jsp can not find the classes. So I copied the *-service.jar to the tomcat lib/ext folder and removed it from the hook when deploying it.
But that doesn't work. After a while I get an exception that says Cache is not alive or this web application instance has been stopped already.
Is there a way to use methods from my custom service builder in the hooked jsp ?
The approach you have taken is correct, i.e. to put the *-service.jar inside [TOMCAT_HOME]/lib/ext and removing the jar from the hook.
The error might be because the hook may not have been properly undeployed, you may get some idea from this forum post. So my suggestion would be to:
Undeploy the hook
Stop the server
Copy the jar to [TOMCAT_HOME]/lib/ext
Clear temp and work directory
Restart the server
Deploy the hook
Whenever you remove a jar from a plugin-project and then just deploy without undeploying the portlet, sometimes you may notice that the jar file may be still present in the deployed webapps/plugin-project's directory, and this might be the case here as well. Also, whenever you put something in the global classpath (i.e. [TOMCAT_HOME]/lib/ext) you need to restart the server.
Also, don't forget to import the class in the JSP :-), just in case ...
We have an Apache tomcat server that runs a current web service. We were trying to deploy a second version (with a few tweaks) however when we copy the war file over, the first one stops working. Why??
Does your webapp contain context.xml configuration for Tomcat? If the two webapps use the same docbase then they are accessing the same folder.
If your application writes to a database, and another copy of it is competing for the same data in the same database, this can result in such behaviour. Does your application write to a "fixed" database? If so, you will need to create another database, or change the way the application deals with the database.
Is the Context root different in the war files. If not I believe the server will not validate the url correctly.
I'm working on a project in Java using the spring framework, hibernate and tomcat.
Background:
I have a form page which takes data, validates, processes it and ultimately persists the data using hibernate. In processing the data I do some special command (model)
manipulation prior to persisting using hibernate.
Problem:
For some reason my onSubmit method is being called twice, the first time through things
are processed properly. However the second time through they are not; and the incorrect
information is being persisted.
I've also noticed that on other pages which are simply pulling information from the data
base and displaying on screen; Double requests are happening there too.
Is there something misconfigured, am I not using spring properly..any help on this would
be great!
Additional Information:
The app is still being developed. In testing the app I'm running into this problem. I'm using the app as I would expect it to be used (single clicks,valid data,etc...)
If you are testing in IE, make note that in some versions of IE it sometimes submits two requests. What browsers are you testing the app in?
There is the javascript issue, if an on click handler is associated with submit button and calls submit() and does not return false to cancel the event bubble.
Could be as simple as users clicking on a link twice, re-submitting a form while the server is still processing the first request, or hitting refresh on a POST-ed page.
Are you doing anything on the server side to account for duplicate requests such as these from your users?
This is a very common problem faced by someone who is starting off. And not very sure about the application eco-system.
To deploy a spring app, we build the war file.
Then we put it inside 'webapps' folder of tomcat.
Then we run the tomcat instance using terminal (I am presuming a linux system).
Now, we set up env in that terminal.
The problem arises when we set up our environment for the spring application where there can be more than one war files to be deployed.
Then we must cater to the fact that the env must be exclusive to a specific war file.
To achieve this, what we can do is create exclusive env files for every war. (e.g. war_1.sh,war_2.sh,.....,war_n.sh) and so on.
Now we can source that particular env file for which we have to deploy its corresponding war. This way we can segregate the multiple wars (applications) and their environment.