Monday, March 8, 2010

Programmer - Map external directory to web.xml

Programmer Question

Is there an easy way to map a directory in the web.xml or other deployment descriptor (jetty.xml, etc) files?



For example, if I have a directory /opt/files/ is there a way that I can access its files and sub-directories by visiting http://localhost/some-mapping/? It strikes me that there should be some simple way of doing this, but I haven't been able to find out how (via google, stackoverflow, etc). All I've found are servlets that mimic fileservers, which is not what I would like.



For reference I am using jetty on an AIX box.



Find the answer here

Programmer - How to reliably get size of C-style array?

Programmer Question

How do I reliably get the size of a C-style array? The method often recommended seems to be to use sizeof, but it doesn't work in the foo function, where x is passed in:



#include <iostream>

void foo(int x[]) {
std::cerr << (sizeof(x) / sizeof(int)); // 2
}

int main(){
int x[] = {1,2,3,4,5};
std::cerr << (sizeof(x) / sizeof(int)); // 5
foo(x);
return 0;
}


Answers to this question recommend sizeof but they don't say that it (apparently?) doesn't work if you pass the array around. So, do I have to use a sentinel instead? (I don't think the users of my foo function can always be trusted to put a sentinel at the end. Of course, I could use std::vector, but then I don't get the nice shorthand syntax {1,2,3,4,5}.)



Find the answer here

Programmer - Jquery Selector not working on Internet Explorer

Programmer Question

Internet Explorer does not like my Jquery selector. Not sure if it's my weak Jquery
skills or general Explorer strangeness.



Here is the Code:



$("#field_"+index+" #field_Label").val();


[div field_1]



<input id="field_Label" //... you get the picture.


to explain this.. I have a DIV labeled field_1, field_2.. etc..
Internet explorer appears to find the first iteration, but cannot
find the second.



Thank you all, and thanks to you stackoverflow.



Is there a better way I should be doing this ?..



Find the answer here

LinkWithin

Related Posts with Thumbnails