This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!

Axel Brown

Greenhorn
+ Follow
since Feb 12, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Axel Brown

Dear Bear Bibeault,
I wanted to tell you that your guidance has helped me to achieve my goal and to thank you for all your help!

10 years ago
JSP

Bear Bibeault wrote:Whether the control was built dynamically with JavaScript or not is moot. When the form is submitted, the state of the form at submission time is all that matters. You need to look at the request parameters that were submitted to know what state to recreate.


Ok, So I got this part working: on submit I get a parameter of the Product and calculation works.
However, when the form gets back to the user my product drop down is empty as it was built via JavaScript/AJAX dynamically on onChange action in brand drop down.

Any way to get that list to the same state as prior submition of the form?
10 years ago
JSP

Bear Bibeault wrote:I see, but the answer is the same. You need to have JSP mechanisms on the page to recreate the state. For example, rather than letting the drop downs cascade, you'll need to fill them in when you know the values in advance.

Basically, test to see if you know a value, and if not, set up the page for initial display, if so, set up the page with the displays showing the values. It's likely to be a lot of <c:if>'s and <c:choose>'s on the page.


This is exactly what I do - I do test to see if I have a value from regular JSP built drop downs. But how can I test the values from dynamically built drop down list via JavaScript?
10 years ago
JSP

Bear Bibeault wrote:There is no way to do that automatically. Anything you dynamically built will be lost on refresh.

You either need to structure the app such that a refresh is not necessary, remember the state and restore it (in the JSP, in the script, or both), or just let it be.

Is there something about your workflow that requires a refresh before the user is done with the form?


By refresh I mean when user clicks a submit button and all the selections go to a servlet and it returns the calculation results back to JSP. User that can do some adjustments based on calculation results and submit again if necessary.
10 years ago
JSP

Bear Bibeault wrote:You can see the examples in action at: http://bibeault.org/jqia2/

And the cascading dropdowns example at: http://bibeault.org/jqia2/chapter8/bootcloset/phase.3.html


Dr. Bear Bibeault, I appreciate all the samples and links! This all new technologies are actually very new to me and I guess I'm too old to understand/learn them...

Even the "old' way I built it, I just do not understand how to connect dynamically built drop down list via JavaScript/AJAX with JSP on Submit action.
So, after submit and JSP reload I still should see the items selected previously. There has to be a way but I can't find it yet.

10 years ago
JSP

Bear Bibeault wrote:Why XML in the response. Again, you taking the more difficult rome. JSON is much preferred as it is much easier to digest on the client side.

Or better yet, if the intent of the response is to provided dat to build the options list, build the options list in the response and just plunk it into the select.

I can point you to some example of doing this sort of thing in jQuery if you are interested.


Any examples would be greatly appreciated!
10 years ago
JSP

Bear Bibeault wrote:

Axel Brown wrote:
Original JSP is loading all products (1000+) into the drop down so I decided to fix this with AJAX.


How is using Ajax going to "fix" this? What's broken? What's being "fixed"?


Apologies for being not clear enough...

The problem is that a product drop down shows currently 1000+ items (list is growing rapidly) and user has to browse through the list in order to select necessary item. I wanted to "fix" this by implementing a Brand Name drop down box that will trigger AJAX call which will populate Product drop down only with around 10-20 items per Brand name. Product table already has brand names associated with each item.
10 years ago
JSP
Hi,

I'm trying to modify an old code to utilze AJAX to populate a product drop down list in JSP.
Original JSP is loading all products (1000+) into the drop down so I decided to fix this with AJAX. I'm not very good at this but have some limited knowledge of Java and need your help!

The problem I have after implementing AJAX drop down box population based on Prodct Brand (which is working) I do not know how to make my selection and drop down population stay after JSP reload after pressing "Calculate" button as I need to do some calculations and get back to the user and still show what he selected before. Not sure how to make this work...


Old JSP form (loads all product brands and products). This is done via set of classes with DAO. After pressing Calculate button all the selections and content are in place

My AJAX implementation:

getProductList servlet returs XML in the following format:


JavaScript that is loaded via separate js file in the header. I got this example from the internet. It does clear the content of the Product drop down as without it drop down was messy and contained previous products from different brand...


I updated JSP Product drop down to make AJAX work. Basically, removed almost everything from it as JavaScript populates it...

My problem is: how can I combain this implementation with my old one so the ComboHelper works and after pressing Calculate and reloading JSP both drop down boxes (Brand and Product) will still have the previosly loaded content and selected in them items?

Many thanks in advance for your help!
10 years ago
JSP

Originally posted by Ben Souther:
It's impossible to say what it could be without seeing the exceptions and the code that's causing them to be thrown.

Rather than trying to manipulate Tomcat into reporting less, I think it would be a better idea to track down what ever is throwing exceptions in your code and get those things fixed.



I know for sure when I shut down DB and my app is trying to connect - I get 10 tomcats logs each 10MB populated in less than a few seconds...
13 years ago

Originally posted by Ben Souther:
I don't think this has anything to do with Tomcat.
Have you verified that the same error is not being thrown repeatedly?



It's the same error just many many times plus its trace is sooo long...
Do you know what it might be?
13 years ago

Originally posted by Joachim Rohde:
Hm... just a random guess:
Are you using Log4j (or is any framework that you are using, using Log4j)? I just remember that I setted the logging-level of a spring-application to 'debug' which generated tons of logging-output.



Log4j, but all settings are with ERROR level only.
When I see the exception in the log it's literally 7-9 pages long - a single exeption...
13 years ago
I don't know how to explain this correctly, but when any Java error occurs Tomcat outputs so huge (very long) stack trace of each error so my logs (which are in rotation of 10 files 10MB each) get filled out in seconds!

Happens usually when there is a DB connection issue and some other cases.

On my old server the stack trace of each error is kind of short and errors has only one or two outputs in log, but on new server each error has like 7-9 pages long stack trace and gets replicated many times.

Any idea?

Thanks!
13 years ago
I think I found the solution
https://coderanch.com/t/87476/Tomcat/include-doesn-recognize-relative-path

I'd appreciate any input on possible security (I do not think there will be any) problems with it.
13 years ago
The solution, which kind of goes against what worked in older versions of Tomcat (I believe 5.5.12), doesn't work for 5.5.25 and 5.5.26 anymore. At least in my case.

So, Context path="" or Context path="/" is no go. I figured a way to make it work by creating a folder ROOT in main domain and each sub-domains and updating Context path as in example below.

So, the folder structure will be like this:

public_html/ROOT
public_html/ROOT/sub-dom1/ROOT
public_html/ROOT/sub-dom2/ROOT
public_html/ROOT/addondomain1/ROOT
...

And all your content should be placed in ROOT of each domain, addon doamin or sub-domain respectively.

Your Host/Context will have to be updated to (note that appBase and docBase stay the same as before):



Also, in Apache's httpd.conf you have to update DocumentRoot to if you want PHP to be working. But this is only if you used JkMount /*
DocumentRoot /home/myuser/public_html/myaddondomain/ROOT

So, it works fine now. Any comments on possible security issues with this structure?
[ February 27, 2008: Message edited by: Axel Brown ]
13 years ago