Let me know !!
Main Topics
Browse All TopicsTutorial : http://www.vaannila.com/sp
I read this and stuck at one place ...need some help.
Here is the flow I see after reading the tutorial..
a request came with url-pattern *.htm
we search for this url-pattern *.htm in web.xml and find out the servlet for this.
we find org.springframework.web.se
DispatcherServlet asks for dispatcher-servlet.xml . We have it ready under WEB-INF folder.
Now the real problem comes here ....
in dispatcher-servlet.xml They say ,
"....The prefix value + view name + suffix value will give the actual view location. Here the actual view location is /WEB-INF/jsp/welcomePage.j
But I don't see any entry for welcomePage.jsp in the dispatcher-servlet.xml . Although there is an entry for prefix , suffix
but there is no entry for view name ? How do we find welcomePage.jsp then ? This is where I am stuck.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
And also ..
in the tutorial it says , DispatcherServlet invokes the HelloWorldController ...But if there were multiple controller like say HelloWorldController-2 , HelloWorldController-3 etc exists then how does DispatcherServlet will decide which controller to call ? what is the deciding factor here ?
U can define welcome page in web.xml file
Like this .....
<welcome-file-list>
<welcome-file>jsp/papa.jsp </welcome-file>
</welcome-file-list>
1.U cant define welcome page in dispatcher-servlet.xml ..
2.<<<<<<<<<<<<<<< one more thing ..this is any view ...need not be so called welcome page !
This is not a view u can call the page directly from here u can call other jsp pages (link or redirect )
3..<<<<<<<<<in the tutorial it says , DispatcherServlet invokes the HelloWorldController ...But if there were multiple controller like say HelloWorldController-2 , HelloWorldController-3 etc exists
depend upon the user request ...
u define the bean name or id is diffrent for each controller like this
in the example code bean name are diffrent
welcome.htm and other one is login.htm
so the , DispatcherServlet diffrencens like this if u give same name means it give error !!
its XML parsing only
>>U can define welcome page in web.xml file
Yea..i know that ...but what I was trying to say is how come they showing welcomePage.jsp without mentioning it in web.xml ?
please download the source code attached in the tutorial....and see the web.xml and dispatcher-servlet.xml .....there is no welcomePage.jsp in web.xml but still they are displaying it . How its picked up ?
<<<< there is no welcomePage.jsp in web.xml but still they are displaying it
1. Ur giving <url-pattern>*.htm</url-patte
2. <property name="suffix">
07. <value>.jsp</value>
08. </property>
here ur metion that all page have suffix .jsp so no need to metion the jsp page.....
3.return new ModelAndView("welcomePage"
here the metion welcomePage so its take it as welcomePage.jsp .... and go to the page...
i think u will get the point !!
>>u can give any name to jsp right ? thats what they did !!!
I think we are in a misunderstanding.
please download this working WAR file they are using for this tutorial
http://www.vaannil
Th
They get "Hello World !"
Now tell, how this view is coming ? I'd like to listen your comments on this.
I checked this WAR file and found that welcomePage.jsp can produce "Hello World !"
but nowhere in the XML this page has not been mentioned. ...thats exactly I am worried about.
Ok once again i explain u ....
I cant d/w the war BCZ i am in office now !!
http://www.vaannila.com/sp
As per web.xml the give welcome page as redirect.jsp so check that
they will redirected to welcome.htm
Then containor check ur DispatcherServlet.xml file
is there any bean name called welcome.htm
as per code it will goto HelloWorldController
<bean name="/welcome.htm" class="com.vaannila.HelloW
<property name="message" value="Hello World!" />
</bean>
In HelloWorldController they have mention return new ModelAndView("welcomePage"
so its go to ur welcomePage.jsp
welcomeMessage this message dispalyed in ur jsp !!
Check
1. In"web.xml", welcome page points to "redirect.jsp" which redirect you to "welcome.htm"
2. DispatcherServlet is handling ".htm" requests, so it invokes "HelloWorldController" as declared in:
<bean name="/welcome.htm" class="com.vaannila.HelloW
<property name="message" value="Hello World!" />
</bean>
3. HelloWorldController return "welcomePage" as its "view", by default it´s going to search for a "welcomePage.jsp" match. Here is where I think you´re getting lost !!! Check out that they are declaring an "InternalResourceViewResol
<bean id="viewResolver" class=" org.springframework.web.se
<property name="prefix">
<value>/WEB-INF/jsp/</valu
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
So, when a Controller (in this case HelloWorldController") returns "welcomePage" as its view, the InterResourceViewResolver is going to search in "WEB-INF/jsp/" for a match and finds "welcomePage.jsp"
Feeling comfortable now.
Still have one doubt .
I'm worried about the HelloWorldController execution flow .
Inside HelloWorldController , It seems to me that first "setMessage" is Injected and then it returns "ModelAndView " so that "InternalResourceViewResol
is that correct ? Can you put some comments on this flow ?
import javax.servlet.http.HttpSer
import javax.servlet.http.HttpSer
import org.springframework.web.se
i
public class HelloWorldController extends AbstractController {
private String message;
@Override
protected ModelAndView handleRequestInternal(Http
return new ModelAndView("welcomePage"
}
public void setMessage(String message) {
this.message = message;
}
}
Business Accounts
Answer for Membership
by: dravidnsrPosted on 2009-11-02 at 23:30:14ID: 25726669
no need for welcome.jsp prefix and suffix
bcz welcome page u defined in web.xml only ...
1st web.xml only loading after that dispartcher -servelet.xml(as per ur code) will soo
after u going to defining page(jsp page) will coming under /WEB-INF/jsp
I think u will get the point !!