Terril Douglas

Greenhorn
+ Follow
since May 05, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Terril Douglas

Hey Mark I think the problem was that my app was going in a loop because the view was the same component that was used to refer to my bean name in the springmvc-server.xml file. So essentially when it returned from the controller the request then looked to use the view which was referring right back to the bean. Sorry for any inconvenience.
Ok I understand what you are talking about and in my controller I did place the view string in the return. I will just post my Controller:

package springmvc.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
//import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

public class HelloWorldController extends AbstractController {
public HelloWorldController(){}

public ModelAndView handleRequestInternal(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

String aMessage = "Hello World MVC!";
//String lo = null;
//ModelAndView modelAndView = new ModelAndView();

return new ModelAndView("hello_world","message",aMessage);
}
}

Originally posted by Mark Spritzler:
I think what the book means is that if you don't return a value for the View String, then it will just go back to the same page it came from. It is the default mechanism.

Mark



The view string is a property that goes in the Controller?
Hello I have been reading SIA 2 and am currently looking at chapter 13.
I am running the example shown in the book and am getting an error.

Using Eclipse I have debugged the app and when the app reaches the controller it continously go back after I return the ModelAndView object.

here are my config files:

web.xml:<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>

springmvc-servlet.xml:

<bean name="/jsp/hello_world.jsp"
class="springmvc.web.HelloWorldController" />

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>

My controller name is HelloWorldController and is working fine. I believe the problem is with the mappings but in the book it specifies that the mapping isn't needed because there is one used by default. Can any one help?

Terril Douglas

Originally posted by Sagar Rohankar:


Use "viewSearch" instead of "/viewSearch".

and let us know whether this helps or not !!



Thanks Sagar this solved the problem pesky forward slash !

Terril
12 years ago
I am trying to use modules to simulate a struts application on a larger scale. I have been having this problem with my forward action tag so I started using

<html:link action="/viewSearch">Search for Employee</html:link>

which was working fine. Now I start using L

<html:link forward="/viewSearch">Search for Employee </html:link>

and the browser is complaining of a MalformedURLException.

Here is how my directory is set up:

MiniHR/index.jsp

MiniHR/employee/search.jsp

MiniHR/reports/menu.jsp

MiniHR/WEB-INF/struts-config.xml
MiniHR/WEB-INF/struts-config-employee.xml
MiniHR/WEB-INF/struts-config-reports.xml
MiniHR/WEB-INF/web.xml

______________________

There is nothing wrong with my stuts files because I can access menu.jsp just fine.

I am having two issues

1) html:link forward="/viewSearch">Search for Employee </html:link>

This gives me this error:
javax.servlet.jsp.JspException: Cannot create rewrite URL: java.net.MalformedURLException: Cannot retrieve ActionForward named /viewSearch

Like I said previously I have used this tag before i even started working with modules and it has never worked so i started using

<html:link action="/viewSearch">Search for Employee</html:link> which works fine. I just want to know why the forward attribute from the html:link tag doesn't work.

My second prob is that since I am using the action attribute of the html:link tag I now get something that says :


javax.servlet.ServletException: No action config found for the specified url.

From my index.jsp page I use the html link page to hit my struts config which is:


struts-config.xml
<global-forwards>
<forward name="viewSearch" path="/employee/viewSearch.do"/>
</global-forwards>

This should map to my struts-config-employee.xml:

<action-mappings>
<action path="/viewSearch" forward="/search.jsp"/>
<action path="/search"
type="com.jamesholmes.minihr.SearchAction"
name="searchForm"
scope="request"
validate="true"
input="/search.jsp">
</action>
</action-mappings>


There is some problem in this step so I am given:

org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url.

If I mapped directly to the module that works but trying to mapped to one config file to the next is causing problems can anyone help with my two probs?

Jamon
12 years ago
Hi I think you have to check your struts-config-main.xml

SO basically where you have the input attribute in your config file:

<action path="/TestDispatch"
type="com.jamesholmes.minihr.TestDispatchAction"
name="TestDispatchForm"
scope="request"
validate="false"
input="/TestDispatch.jsp"
parameter="function"/>

With that findForward it will go to TestDispatch.jsp. I believe this is how it works I guess someone can correct me if I am wrong hope this works.

Jamon
12 years ago
I am trying to use modules to simulate a struts application on a larger scale. I have been having this problem with my forward action tag so I started using

<html:link action="/viewSearch">Search for Employee</html:link>

which was working fine. Now I start using L

<html:link forward="/viewSearch">Search for Employee </html:link>

and the browser is complaining of a MalformedURLException.

Here is how my directory is set up:

MiniHR/index.jsp

MiniHR/employee/search.jsp

MiniHR/reports/menu.jsp

MiniHR/WEB-INF/struts-config.xml
MiniHR/WEB-INF/struts-config-employee.xml
MiniHR/WEB-INF/struts-config-reports.xml
MiniHR/WEB-INF/web.xml

______________________

There is nothing wrong with my stuts files because I can access menu.jsp just fine.

I am having two issues

1) html:link forward="/viewSearch">Search for Employee </html:link>

This gives me this error:
javax.servlet.jsp.JspException: Cannot create rewrite URL: java.net.MalformedURLException: Cannot retrieve ActionForward named /viewSearch

Like I said previously I have used this tag before i even started working with modules and it has never worked so i started using

<html:link action="/viewSearch">Search for Employee</html:link> which works fine. I just want to know why the forward attribute from the html:link tag doesn't work.

My second prob is that since I am using the action attribute of the html:link tag I now get something that says :


javax.servlet.ServletException: No action config found for the specified url.

From my index.jsp page I use the html link page to hit my struts config which is:


struts-config.xml
<global-forwards>
<forward name="viewSearch" path="/employee/viewSearch.do"/>
</global-forwards>

This should map to my struts-config-employee.xml:

<action-mappings>
<action path="/viewSearch" forward="/search.jsp"/>
<action path="/search"
type="com.jamesholmes.minihr.SearchAction"
name="searchForm"
scope="request"
validate="true"
input="/search.jsp">
</action>
</action-mappings>


There is some problem in this step so I am given:

org.apache.struts.chain.commands.InvalidPathException: No action config found for the specified url.

If I mapped directly to the module that works but trying to mapped to one config file to the next is causing problems can anyone help with my two probs?

Jamon
12 years ago
Hello looking at the code snippet here:

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
env.put(Context.PROVIDER_URL, "file:/tmp/tutorial");
Context ctx = new InitialContext(env);

I am wondering for the env variables how do you know how to set up the service provider?

env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
12 years ago
Thanks folks, I was going through some docs and I didn't know that everytime you make a change to the env variables you also need to open a new dos window to get the new changes.
12 years ago
Hi

I have installed my jdk 1.5 and went to system properties because at the cmd i can type java to execute programs but I can't compile my code it tells me the compiler isn't recognized.

I am running XP Professional.

Thanks
12 years ago