Jsp:forward in Java without using JSP tag?

The someObject you are looking for is pageContext This object is implicitly defined in JSP, so you can use it like this: pageContext. Forward("").

The someObject you are looking for is pageContext. This object is implicitly defined in JSP, so you can use it like this: pageContext. Forward("").

Good call! That's cleaner than getting the dispatcher explicitly. – erickson Oct 28 '08 at 23:38.

You really should try and avoid scriplets if you can, and in your case, a lot of what you are doing can be replaced with JSTL code. The following replacement for your example is much cleaner, IMO: Ideally, you'd modify error. Jsp so that the error message doesn't even need to be set in the session, but I didn't want to change your design too much.

– Chris Carruthers Oct 29 '08 at 9:23 It's never been clear to me what the advantage of JSTL over plain scriptlets is. I've seen discussions that say that this allows non-programmers to create dynamic web pages because you don't have to know Java. But really now, just look at the example above: How is this NOT "programming"?

Sure, it's not Java, but by any rational definition it is a programming language. So instead of learning and using Java, you can learn and use Java AND learn and use another language. What is gained, besides adding to the amount you have to learn?

– Jay Oct 4 '09 at 3:46 I'm with the scriptlet people here. It's less code, avoids the clumsy syntax, and faster, because the EL expression in the when is parsed as a string each time it's run, whereas the java code is compiled. – davidsheldon Jan 18 '10 at 18:36 @Jay et al, you do bring up a good point.

In this case, JSP is simply being used (IMO, abused) as a programming language, as such it doesn't really matter. IMO, however, JSP should be used strictly as a templating engine, with only presentation logic (i.e. , no controller logic, which is what we're doing here, or worse, business logic).

– Jack Leow Jan 18 '10 at 18:45 I think there are good arguments to be made on both sides of "JSP as a programming language" versus "JSP as a template engine with servlets or whatever for business logic". (And I think the best argument AGAINST JSP as a programming language is: Sooner or later, you discover it's inadequate and have to do something else anyway.So why not do it sooner and be consistent? ) But I really don't see the value of JSTL.

It's just another programming language to learn, and a very weak one at that. – Jay Jan 19 '10 at 21:31.

A simple approach: Error. Jsp ......... Better approach: Invoke the doSomething() from a servlet. Set your error page in web.

Xml java.lang. Exception /WEB-INF/jsp/Error.jsp.

Personally -- and this is a totally personal preference, perhaps -- I think it's easier to do my flow control in JSP rather than with a combination of JSP, servlets, and web. Xml settings. And the reason is illustrated by that sentence: If I do it all in JSP, then it's in one place, instead of three.

– Jay Oct 4 '09 at 3:48.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions