Questionsforum
What happened if we directly request for a resource from the browser in SpringMVC?

What happened if we directly request for a resource from the browser in SpringMVC?



On 2014-06-16 12:48:12.0
sushant


If you mean to say without initializing the Spring Container you want to process the request how can you do this ?



On 2014-06-16 12:54:21.0
hablu

No i doesn't mean that, all i mean is requesting the resource ( display.jsp ) from browser after starting the server and with the complete path i.e http://localhost:8080/SpringMVC/display.jsp , then what will happen , will Spring Container will able to display the Requested jsp from the Browser if we have used spring tld file to represent the form in that jsp??



On 2014-06-18 04:26:53.0
sushant

@sushant You need to initialize the spring container first than only the request can be processed. All the first first step that you are going to take is for spring container start up only.



On 2014-06-18 04:51:16.0
hablu

WebApplicationContext will automatically created by the DsipatcherServlet while reading the web.xml, so no need to create initialize any Container explicitly. Consider me question after initializing the Spring Container.



On 2014-06-18 05:05:54.0
sushant

@sushant it will execute what will restrict it's execution ?



On 2014-06-18 05:59:26.0
hablu

I think requesting for the resource which is having Spring form tag will make Spring Container to behave little different. It display error says " WebApplicationContext is not initliazed " when we are directly requesting for the resource ( jsp having Spring form tags ) .



On 2014-06-18 09:27:42.0
sushant

See actually when you are directly going to call something.jsp it will not execute the mapped controller what you have configured in web.xml file like

<servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>fully qualified path of DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>

and hence ApplicationContext is not going to start so any spring specific tag will land with an error showing WebApplicationContext is not initliazed You should have to execute DispatcherServlet in order to make that tag working.



On 2014-06-18 09:59:17.0
hablu

Yeah exactly and add to this, When we are using any Spring specific form tag in our jsp page then DispatcherServlet is expecting requested URI of the resource jsp so that it will collect the information about its Controller class and then can able to call formBackingObject() which return command class instance and hence DispatcherServlet will able to populate the value set in the formBackingObject() method using setter method of the command class.



On 2014-06-18 11:51:44.0
sushant

copyright@questionsforum.net