Sebastian Janisch wrote:Every JSP page gets translated into a plain old Servlet by the container.
So, even if your JSP contains only static html content, the container couldn't care less :-) .
In case you care to see what the JSP is getting translated to, check the 'work' directory in your Tomcat installation folder.
Watch out though, it's getting messy
Bear Bibeault wrote:It is customary to place JSPs under a folder within WEB-INF. There, they cannot be served directly and can only be accessed via a forward from another resource (such as a servlet).
Bear Bibeault wrote:Even if it weren't the case, again, using a JSP to collect the data and then forward to a servlet is just bizarre.
In any case, check out BeanUtils.populate() to get the same effect.
Bear Bibeault wrote:It is not proper. As pointed out, submitting to a JSP just so you can use the old-fashioned setProperties tag is just awkward.
Submit to a servlet and grab the values from the request and set them into the bean in Java code. if you would like "bean assist", check out the Jakarta commons BeanUtils project.
Bear Bibeault wrote:First, why share the controller in this way? Why does each page not get its own controller? Do you have a good reason for the sharing?
Secondly, it's a bad idea to switch based upon implicit information such as where the page came from. This makes you code tightly coupled and fragile. Better to use explicit information such as a parameter.
Alternate ways:
1.QueryString parameter
2. wild card servlet mapping
seetharaman venkatasamy wrote:
Peter Maxwell wrote:
Is this possible/good idea?
Possible . It is not a bad idea, since servlet is a good controller. and you need to check the input parameters(which are from the jsps) in servlet using else if or switch
Bear Bibeault wrote:
It's a common nomenclature usage that somehow got started. No need for the red face.Peter Maxwell wrote:
Well that's so embarrassing, as i've always called it that way.
Thanks, that looks like a simple and elegant solution for this and that solves my problem.
Just basic HTML.
But just out of curiosity is there anyway that EL can do this?
Not on its own. Remember, the EL is purposefully hobbled to only allow display type interaction as a way to dissuade people from doing non-view calculations in JSPs. However, the fn class of EL functions in the JSTL allow a certain amount of string manipulation. But again, it should not be misused for data processing.
Bear Bibeault wrote:Welcome to the Ranch.
A couple of things:
It's not a "combo box", no such control exists on the web. Please read this for more information.
Bear Bibeault wrote:
Secondly, rather than trying to parse out part of the display value, use the value attribute on the option elements to submit extactly what you need and nothing else.
Bear Bibeault wrote:
You might also want to read through this article to find out why submitting directly to a JSP is not considered a best practice.