• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using a bean and jsp problem

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to use a bean in my jsp pages.
The bean will use the getServletPath, I think.
Below is the bean to get the url. If it is a -e.jsp or a -e.html if you click the link, it should switch it to the exact page in the opposite language -f.jsp or -f.html
on my jsp page I have:
<jsp:useBean id="toggle" class="ToggleBean" scope = "request"/>
<jsp:setProperty name="toggle" property="oldAddress" value="language-e.jsp">
<a href = "<jsp:getProperty name="toggle" property="newAddress"/>Fran�ais</a>
and the ToggleBean:
import java.util.*;
public class ToggleBean
{
String oldAddress = null;
String newAddress = null;
public String getoldAddress()
{
return oldAddress; //method not used
}
public void setoldAddress(String str)
{
oldAddress = str;
toggleAddress();
}
public String getnewAddress()
{
return newAddress;
}
public void setnewAddress(String str)
{
newAddress = str; //method not used
}
private void toggleAddress()
{
String str = oldAddress;
if(!((str.endsWith(".htm")) | | (str.endsWith(".jsp")) | | (str.endsWith(".html"))))
{ //This program is to be used only for files names ending with .htm, .html or .jsp
newAddress= null;
return;
}

int pos = str.lastIndexOf('.');
if(pos < 0){ newAddress= null; return;}
char langCode = str.charAt(pos-1);
if(langCode =='e')
{
StringBuffer sb =new StringBuffer(str);
sb.setCharAt(pos-1,'f');
newAddress = sb.toString();
}
else
if(langCode=='f')
{
StringBuffer sb =new StringBuffer(str);
sb.setCharAt(pos-1,'e');
newAddress = sb.toString();
}
else
newAddress= null;
}
}
What is wrong? I get the below error.
javax.servlet.ServletException: Exception thrown running XT: Expected "" to terminate element starting on line 2.
org.xml.sax.SAXParseException: Expected "" to terminate element starting on line 2.
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Terminate element is missing in your bean property declaration. The bean property setting should be defined as
<jsp:setProperty name="bean" property="prop" param="prop"/>
cheers,
mpr
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic