Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!

Steve Dyke

Ranch Hand
+ Follow
since Nov 16, 2004
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
7
Received in last 30 days
0
Total given
11
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Steve Dyke

Bear Bibeault wrote:OK, the formatting of the code made me miss where the handler was passed.

No, as it simplest, a POST is mostly used when a non-idempotent operation is to be executed on the server. There's a little more than that to it, but that'll do for our purposes.

Getting data, even if its pre-formatted HTML, is clearly a GET.

And, if the intent is to load the formatted HTML returned as the response into the DOM, that's where the jQuery .load() method is really handy.



Still is not working as expected, but closer.

My AJAX call:



My servlet code:



Console output:

<select class='ncrquefilterinputs_select ncrvc r-margin' data-inputfield='vendorcode' data-quefiltersource='search'>
<c:forEach var='itemName3' varStatus='status3' items='${defaultpramsObj.vendorList}'>
<option value='${itemName3.optionValue}'>${itemName3.optionDesc}</option>
</c:forEach></select>

My container code:



The select2 list is displayed with only one item - "${itemName3.optionDesc}"
1 week ago
JSP

Bear Bibeault wrote:In your Ajax logic, where do you do anything with the response?

And why is it a POST?



Return code:(I thought this handled the response.)



I thought you used a post if the servlet response was not dispatching another view.

I learn every day and I thank you for all the help you have been over the years.
1 week ago
JSP

Steve Dyke wrote:

Bear Bibeault wrote:What is it that you are trying to do here:?



My first select list each option has a data attribute that associates to a session defined list. I want to assign this data attribute to the wValue3 variable.

After thinking about this the only way I may get it to work is by using ajax. But you may have a better way I am hoping. 



I have tried the AJAX method, the list displays but is not populated as expected.



Servlet code:



Console display:
NCRV8ControllerServlet: jReturnString: {"testThisReturn": "<select class='ncrquefilterinputs_select ncrvc r-margin' data-inputfield='vendorcode' data-quefiltersource='search'>
<c:forEach var='itemName3' varStatus='status3' items='${defaultpramsObj.vendorList}'><option value='${itemName3.optionValue}'>${itemName3.optionDesc}</option>
</c:forEach></select>"}


Return code:

1 week ago
JSP

Bear Bibeault wrote:What is it that you are trying to do here:?



My first select list each option has a data attribute that associates to a session defined list. I want to assign this data attribute to the wValue3 variable.

After thinking about this the only way I may get it to work is by using ajax. But you may have a better way I am hoping. 
1 week ago
JSP
I am trying to make my jsp container as dynamic as possible. However, in my js I get an error when the container is called on line 85 of code.



Console output:

...
[9/17/18 16:46:58:693 CDT] 00000080 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [QMSWebAppEAR] [/QMSWebApp] [/NCRV8/NCRV8-Queue/NCRQueueDisplayForm.jsp]: Initialization successful.
[9/17/18 16:46:58:679 CDT] 00000080 SystemErr     R javax.el.PropertyNotFoundException: Property 'optionValue' not found on type java.lang.String
[9/17/18 16:46:58:679 CDT] 00000080 SystemErr     R at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:232)
[9/17/18 16:46:58:679 CDT] 00000080 SystemErr     R at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:209)
[9/17/18 16:46:58:679 CDT] 00000080 SystemErr     R at javax.el.BeanELResolver.property(BeanELResolver.java:319)
[9/17/18 16:46:58:679 CDT] 00000080 SystemErr     R at javax.el.BeanELResolver.getValue(BeanELResolver.java:89)
[9/17/18 16:46:58:679 CDT] 00000080 SystemErr     R at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:55)
[9/17/18 16:46:58:679 CDT] 00000080 SystemErr     R at org.apache.el.parser.AstValue.getValue(AstValue.java:174)
[9/17/18 16:46:58:680 CDT] 00000080 SystemErr     R at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:283)
[9/17/18 16:46:58:680 CDT] 00000080 SystemErr     R at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:778)
...
1 week ago
JSP

Bear Bibeault wrote:You are looking for the attribute on the function context (this) in the handler. Is that really where you need to be looking for it?



I see what you mean. I got this to work. Thanks for the help:

Bear Bibeault wrote:You are looking for the attribute on the function context (this) in the handler. Is that really where you need to be looking for it?



I see what you mean. I have changed to this but get undefined now:


I get a null return when attempting to access the value of a data attribute from an option tag.

This is the html code

Tim Holloway wrote:

Steve Dyke wrote:In the log on servlet





Can you elaborate please?
2 weeks ago

Steve Dyke wrote:

Tim Holloway wrote:Long before there were webapps, or for that matter, even the Internet, I learned the hard way that global variables can be a real nightmare. So keep them to a minimum.



Thanks for the insight. My quest is to reduce the number of objects having to be created on the heap. I have "Out of Memory" issues from time to time. I thought that minimizing the number of times a class is constructed might help.

My JVM is set to 3G already. My compiled app(deployed) size is almost 1G. The app will run for several days even a week or more then the heap size grows beyond the max.



I think I may have a different approach to the more dynamic lists. The app contains what I call modules, set up as a navigation menu. Not every user needs access or has access to every module.
They can pick and choose which ones they want in their menu to a certain extent.
In the log on servlet I could analyze the module criteria and determine which lists it would need and load these into session attributes.

As I have stated before, currently every list loads into a default class set to a session attribute when the first servlet in app is called even if it is never accessed.
2 weeks ago

Tim Holloway wrote:Long before there were webapps, or for that matter, even the Internet, I learned the hard way that global variables can be a real nightmare. So keep them to a minimum.



Thanks for the insight. My quest is to reduce the number of objects having to be created on the heap. I have "Out of Memory" issues from time to time. I thought that minimizing the number of times a class is constructed might help.

My JVM is set to 3G already. My compiled app(deployed) size is almost 1G. The app will run for several days even a week or more then the heap size grows beyond the max.
2 weeks ago

Bear Bibeault wrote:ServletContext.getAttribute()

Of course, you've got to put it there first.

Think about it, of what use is sticking it into a member variable of the listener? You want to put all your "global" data into the application context (aka ServletContext).



This is what I have now and it seems to work when I use it in my JSTL code.

2 weeks ago

Paul Clapham wrote:Execute code on webapp startup and shutdown using ServletContextListener

To that I would add: from the ServletContextEvent object passed to the contextInitialized method you can get a ServletContext; to add an object to application scope you can call its setAttribute(name, object) method. Elsewhere in your app you can easily get a ServletContext and call getAttribute(name) to retrieve that object, or in JSTL it's very easy to access objects in application scope.



Still not sure I am doing this correctly:

I have my listener created and a list added to it. How do I access the list in my app?

2 weeks ago

Paul Clapham wrote: ...then you should be putting them in application scope rather than in session scope...



First thanks for your help in this matter.

So would the lists get loaded when I started the application server? If changes were made I could just restart the server.

Is there a certain way or place I put the list so they belong to the application? I am using WebSphere and eclipse. Or do I have to do this on the application server?
2 weeks ago
Was not sure what to put in subject line and not sure this is the correct forum.

In my web app I have a function that runs when first loading where I create several(50+) class objects that hold various lists that will be used in the application. I assign this function output to a session attribute so the app can access it.

For example a list of supplier names and data. This list is populated from a remote data result.

Each time a user accesses the application(separate session of the application) this list would be created for that session. Or I assume this is what is happening.

Here is my application design question. Is there a way that these lists could be at some global level in the application so each session would not have to construct its own class object of the list?

Is this sort of thing a candidate for a Web Service? Would this be more efficient? Or is the way I have it designed the correct way?

I an trying to reduce the heap size of the application. 
2 weeks ago