Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > jsp mapping

Reply
Thread Tools

jsp mapping

 
 
homecurr@yahoo.com
Guest
Posts: n/a
 
      04-20-2004
I am using tomcat. In the web.xml for a webapp, I can do servlet mapping like

<servlet-mapping>
<servlet-name>myServlet</servlet-name>
<url-pattern>/m</url-pattern>
</servlet-mapping>

Can I map a jsp?

Thanks,

John
 
Reply With Quote
 
 
 
 
kd
Guest
Posts: n/a
 
      04-21-2004
Not the way your thinking of. But maybe the ff will help.

You can map a welcome page, ie www.mycompany.com maps to
www.mycompany.com/helloppl.jsp

Otherwise one accesses JSP's directly, for instance,
localhost/mywebapp/jspfolder/Hello.jsp

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I am using tomcat. In the web.xml for a webapp, I can do servlet mapping like
>
> <servlet-mapping>
> <servlet-name>myServlet</servlet-name>
> <url-pattern>/m</url-pattern>
> </servlet-mapping>
>
> Can I map a jsp?
>
> Thanks,
>
> John

 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      04-21-2004
kd wrote:
> Not the way your thinking of. But maybe the ff will help.
>
> You can map a welcome page, ie www.mycompany.com maps to
> www.mycompany.com/helloppl.jsp
>
> Otherwise one accesses JSP's directly, for instance,
> localhost/mywebapp/jspfolder/Hello.jsp


Or it's simple to write a servlet that simply forwards (or redirects) to
a JSP, and then map that.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
Michael Scovetta
Guest
Posts: n/a
 
      04-21-2004
Check down a bit in your web.xml, or possible server.xml or one of the
..xml config files, you should see something like
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>logVerbosityLevel</param-name>
<param-value>WARNING</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>

and then a bit down lower

<!-- The mapping for the JSP servlet -->
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>

That's the only reason that .jsp files are interpreted as such.

Oh, my bad, well I think this post might be relvant anyway so I'll
post
it anyway.

So you want to map http://server/m to /foobar.jsp? Yeah, I would just
set up a nice Redirector Servlet:

public class RedirectorServlet extends HttpServlet {
private String redirect = null;

public void init() throws ServletException {
this.redirect = getInitParameter("redirect");
}

public void doGet( HttpServletRequest request,
HttpServletResponse response )
throws ServletException, IOException {
if (redirect == null)
throw new ServletException("Cannot redirect to null.");
else
response.sendRedirect(redirect);
}
}

and then have in your web.xml:
<servlet>
<servlet-name>redirector</servlet-name>
<servlet-class>com.scovetta.Redirector</servlet-class>
<init-param>
<param-name>redirect</param-name>
<param-value>/foobar.jsp</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>redirector</servlet-name>
<url-pattern>/m</url-pattern>
</servlet-mapping>

That should handle what you want-- you might need to make the url
pattern
/m/* or /m*, I haven't tested it.

Hope that helps--
Mike Scovetta

(E-Mail Removed) wrote in message news:<(E-Mail Removed). com>...
> I am using tomcat. In the web.xml for a webapp, I can do servlet mapping like
>
> <servlet-mapping>
> <servlet-name>myServlet</servlet-name>
> <url-pattern>/m</url-pattern>
> </servlet-mapping>
>
> Can I map a jsp?
>
> Thanks,
>
> John

 
Reply With Quote
 
javaexp javaexp is offline
Junior Member
Join Date: Apr 2013
Posts: 1
 
      04-18-2013
Wanted to add more info to this old thread:

Apart from using redirection, <jsp-file> tag, we can also map the servlet class file corresponding to that JSP. This servlet class is present in the work folder of any server like Tomcat, JBOSS.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Struts] action mapping to jsp pages under WEB-INF mlubino@gmail.com Java 1 02-24-2007 04:02 AM
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM
JSP mapping an HTML control to a Java bean ccjjharmon@gmail.com Java 4 04-11-2006 10:11 PM
Custom tags and <jsp:plugin> / <jsp:param> Raymond DeCampo Java 0 02-18-2004 01:29 AM
[JSP] Strings Constants from JSP using Struts tags Matthias Nietz Java 1 11-12-2003 04:32 PM



Advertisments