Le me just state up front that I am a hack JSP guy, but this seems pretty simple. The environment is a linux distro using tomcat6 as a web server / jsp container.
Sorry about the formating here, i am really new to this editor!
The Cisco XML menu syntax is as follows:
<CiscoIPPhoneMenu>
<Prompt>Select an entry to dial</Prompt>
<MenuItem>
<Name>Wes</Name>
<URL>Dial:32081</URL>
</MenuItem>
<MenuItem>
<Name>Steve</Name>
<URL>Dial:32082</URL>
</MenuItem>
<MenuItem>
<Name>Mike</Name>
<URL>Dial:32538</URL>
</MenuItem>
</CiscoIPPhoneMenu>
The text file looks like this:
#Comment lines prefaced with #
Wes,32081
Steve,32082
Mike,32538
So the JSP does the following:
1. Create the XML header
2. Repeat for each line in the file:
a. Read and parse a line of text
b. Write the XML directory entry
3. Write the closing XML tags
Pretty simple. Here is the result:
<%@page contentType="text/xml" pageEncoding="UTF-8"%>
<%@ page import="java.io.*" %>
<CiscoIPPhoneMenu>
<% try {
BufferedReader br = new BufferedReader(new FileReader("/srv/www/tomcat6/webapps/ROOT/teldir/pb.txt"));%>
<Prompt>Select an entry to dial</Prompt><%
try {
String line = null;
while (( line = br.readLine()) != null) {
if (!line.substring(0,1).equals("#")) {
String[] d=line.split(","); %>
<MenuItem><Name><%= d[0] %></Name>
<URL>Dial:<%= d[1] %></URL>
</MenuItem><%
}
}
} finally {
br.close();
}
} catch (IOException ex){%>
<Prompt>Directory File Not Found</Prompt><%
ex.printStackTrace(); }%>
</CiscoIPPhoneMenu>
This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post. check here
ReplyDeleteThank you a bunch for sharing this with all of us you actually realize what you are talking about! Bookmarked. Please also seek advice from my site =). We could have a hyperlink change contract between us!
ReplyDeleteI havent any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. bookmetoday.com
ReplyDelete