aspose file tools*
The moose likes Struts and the fly likes <html:link> with Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "<html:link> with Struts" Watch "<html:link> with Struts" New topic
Author

<html:link> with Struts

Charles Van Damme
Greenhorn

Joined: Feb 24, 2009
Posts: 19
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) ?

Note 3:
- 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.

My development environment :

- IDE NetBeans 6.1
- Serveur Tomcat 5.0
- JSP
- JSTL 1.1
- Java JDK 1.6.0_07


Is there a brave and illuminated soul who ... ? Thanks in advance.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Did you try using the "action" attribute, <html:link action="MC_LowRight_02"/>?
Charles Van Damme
Greenhorn

Joined: Feb 24, 2009
Posts: 19
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 ?

Hum !
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 ?

Once again, many thanks.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The "name" attribute was deprecated back in Struts 1.1 (see the Struts 1.1 form tag documentation), and removed in Struts 1.2.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: <html:link> with Struts