Solved

JSP, HTML to WAP

Posted on 2003-11-14
3
664 Views
Last Modified: 2013-12-27
Hello experts! :)

I need your help in this. I have been working in the past a bit with wml so I am not completeley irrelevant on it (although I have forgotten most of it by now), the problem is that back then I created wml pages only for WAP browsers, now I have a hole web site that I want to be able to be seen from WAP and WEB browsers. Till now the site works perfectly in WEB but it is mainly .jsp pages so I am not sure how to dynamically transform them in wml when there is a request from WAP browser. Another thing : will it be a problem that my site is secure ?(https://...) In my browser it asks for accepting a certificate every time you connect, how will this work in WAP?
In case it matters I am using Tomcat but as I have seen this shouldnt be a problem.
I saw that there is also some kind of filter that makes all this automatically, how good does this work? Does anyone have any experience on this kind of filters-transformers?

Thanks again. Anna
0
Comment
Question by:annasfe
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
jimmack earned 125 total points
Comment Utility
Hi Anna,

I have my web site set up with a Servlet filter that simply redirects a user to either the WAP or HTML (JSP) pages.  You'll probably find that you have more control if you create seperate WML and HTML (JSP) pages.  If your JSP pages use anything beyond the simplest HTML code, you'll probably lose a lot (or possibly too much) in the translation process.

https URLs can be accessed by some of the newer mobile phones that have browsers that support it, but you shouldn't count on that ;-)

Setting up the filter in Tomcat is fairly straight-forward.

In the WEB-INF/web.xml file, add the following:

    <filter>
      <filter-name>IndexRequestFilter</filter-name>
      <filter-class>my.domain.name.IndexFilter</filter-class>
    </filter>

    <filter-mapping>
      <filter-name>IndexRequestFilter</filter-name>
      <url-pattern>/index.jsp</url-pattern>
    </filter-mapping>

And then create the IndexFilter class:

package my.domain.name;

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 * This class is used to intercept requests for the default index page
 * (index.jsp).  It checks to see if the requesting client is a mobile
 * phone and if so, returns <B>index.wml</B>.  Otherwise, it returns the
 * originally requested <B>index.jsp</B> page.
 */
public class IndexFilter implements Filter
{
    private ServletContext context;

    public void init(FilterConfig config)
    {
        context = config.getServletContext();
    }

    public void doFilter(ServletRequest request,
                         ServletResponse response,
                         FilterChain chain) throws ServletException, IOException
    {
        HttpServletRequest req = (HttpServletRequest)request;
        HttpServletResponse resp = (HttpServletResponse)response;

        String acceptHeader = req.getHeader("accept");
        if (acceptHeader.indexOf("vnd.wap.wml") != -1)
        {
            resp.sendRedirect("http://my.domain.name/index.wml");
        }
        else
        {
            chain.doFilter(request, response);  // otherwise continue to orginally requested page (index.jsp)
        }
    }

    public void destroy()
    {
    }
}


Hope that helps.

Jim.
0
 

Author Comment

by:annasfe
Comment Utility
As I understood is better to not use the translator filter (my jsp pages does not use only simple html, they have connection with database stuff, scripts,frames etc). So the question is now, do I have to start copying all of them to wml? Is there any way to make this process easier?

Thanks again, I will try to use the filter you send me in order to redirect to the jsp-wml pages.
Hope it works cause when I was trying to put the tranform-filter to the web.xml file it caused me some kind of error and then the normal page was not working either...no idea why...
Anyway, the point are yours ;)
0
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
;-)  Thanx.

I'm sorry to say that with the more complex pages (like the ones you have), you are probably going to have the best results if you write the WML specifically for them :-(
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

MAC Filtering: MAC filtering is like handing a list of names to a doorman. If someone comes to the door and mentions a name, this name is checked by the doorman on his list and granted or denied access by this. This means that if someone menti…
DECT technology has become a popular standard for wireless voice communication. DECT devices are not likely to be affected by other electronic devices and signals because they operate in a separate frequency-band.
This Micro Tutorial will show you how to maximize your wireless card to its maximum capability. This will be demonstrated using Intel(R) Centrino(R) Wireless-N 2230 wireless card on Windows 8 operating system.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now