JSP, HTML to WAP

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
annasfeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jimmackCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
annasfeAuthor Commented:
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
jimmackCommented:
;-)  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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Wireless Networking

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.