Originally developed in JSP, my MVC application is running well, and among others all the hyperlink calls.
Basically, I have a <frameset> used as base page and which contains at the left side (LowLeftWin) a menu whose items are all hyperlinks calling pages that have to be displayed in the right window (LowRightWin).
When I transform my JSP pages in Struts (to learn Struts), a problem appears : At the start of the website loading, I don't get the menu (left window) anymore, while I obtain well the first page (right window)
Note 1: The base page is the only one not containing Struts elements, only JSP elements (and located under 'Web Pages'). The calls to the menu (MC_LowLeft_1.jsp) and to the first page to display (MC_LowRight_01.jsp) are direct calls to JSP files.
All the other pages are (to be) converted with Struts elements and have subsequently the
directive at the top of the file. Also, they all reside in a subdirectory : 'Views'.
If the 'MC_LowLeft_1.jsp' page does not contain a <html:link ... element, but
, the problem does not appear and all the hyperlinks of the menu are operating well.
As soon as I substitute the html code at one place by the equivalent Struts element
, the problem appears.
... Exception in JSP: /Views/MC_LowLeft_1.jsp:19
19: <li><html:link page="/MC_LowRight_02.do" >
cause mère : java.lang.NullPointerException
We know that the '<html:link>' element generates a link pointing to '/C/page', where ...
- 'C' is the application context : Here 'Vehic'
- 'page' is a URL, as written in the 'page' attribute of the '<html:link>' element.
From the code of the 'Views/MC_LowLeft_1.jsp' page, Struts generates in fact :
, making this way a call to 'struts-config.xml' which contains the 'action' element calling on its turn 'MC_LowRight_02.jsp'.
Here is my question of this session : How to code correctly the URL of the page to call in
so that there is no exception mention anymore, that the menu '/Views/MC_LowLeft_1.jsp' appears and that I can operate any hyperlink of the menu (to call 'MC_LowRight_02.jsp', for instance) ?
- The 'web.xml', 'struts-config.xml' and 'struts-html.tld' files are well located in the directory 'Web Pages/WEB-INF'.
- The 'web.xml' file does contain the necessary <servlet> and <servlet-mapping> to use the action 'ActionServlet'.
- The 'struts-config.xml' file contains
n for the cases where a <form> or a URL from another page must be able to call this '/Views/MC_LowRight_02.jsp' page.
Did you try using the "action" attribute, <html:link action="MC_LowRight_02"/>?
Charles Van Damme
Joined: Feb 24, 2009
CONGRATULATIONS, you hit it !
When I use "action" instead of "page" in the <html:link tag, my menu of hyperlings appears as it ought in my left frame.
and each hyperlink calls the right JSP page in the right frame.
But why, in the tutorial (August 2004), can I see only 'page' ?
When I place the cursor just at the back of <html:link , a list of information and attributes pops up. Both 'page' and 'action' are in it. How could I know ?
In a further page, similar problem, but regarding the 'html:form' tag :
Attribute name invalid for tag form, according to TLD
In the popup list, no mention of the attributes 'name' nor 'type'.
Do I have a problem of version of Struts and TLD ?