You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Adam Koch <ad...@dogtired.org> on 2007/09/19 15:58:08 UTC

Can't access Javascript/CSS when in servletMode

I'm wondering if anyone else has seen this problem and if it's a known bug
or if I'm doing something wrong.

I'm using 1.3.0-SNAPSHOT on Weblogic 8.1. When I have Wicket set up in
web.xml as a servlet, any request to /myApp/myJS.js (or
/myApp/resources/myJS.js or /myApp/com/.../myJS.js) gets stripped and the
page is redirected to the home page.

When I say stripped, I'm referring to this code:
    public String getRelativePath(HttpServletRequest request)
    {
        String path = Strings.stripJSessionId(request.getRequestURI());
        String contextPath = request.getContextPath();
        path = path.substring(contextPath.length());
        if (servletMode)
        {
            String servletPath = request.getServletPath();
            path = path.substring(servletPath.length()); // <--- javascript
is stripped out of the path. Weblogic 8.1 problem?
        }
...

Once I changed the web.xml to use a filter instead, it worked.

In fact, I couldn't get the JS/CSS in any way when using the servlet. I
tried putting the JS in my app.war in these directories:
/ (root)
/classes/com/.../someJS.js
/WEB-INF/classes/com/.../someJS.js (same directory as Class and html)

I tried :
response.renderJavascriptReference("common.js");
add(HeaderContributor.forJavaScript( MYPAGE_JS ));
add(new JavaScriptReference("commonjs", getClass(), "common.js"));

and none worked with the Wicket in servletMode. (All sent me to home page.)

I haven't tried these ways to insert the JS in filter mode. I've just used:
<script language="JavaScript" type="text/javascript" src="common.js
"></script>
I'm going back and seeing if any/all of those work now that I've switched to
a filter.

Thanks for reading!

Adam

Re: Can't access Javascript/CSS when in servletMode

Posted by Kent Tong <ke...@cpttm.org.mo>.

Adam Koch wrote:
> 
> It is mapped to an app and not to the root. The directories I listed
> are in the war file, but I tried to access them with
> http://localhost/myapp/ ... 
> 

Then I'd suggest you:
1) deploy your app in Tomcat to see if it works.
2) file a jira issue and upload a bare minimal app showing the problem.

-- 
View this message in context: http://www.nabble.com/Can%27t-access-Javascript-CSS-when-in-servletMode-tf4481265.html#a12913394
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can't access Javascript/CSS when in servletMode

Posted by Martijn Dashorst <ma...@gmail.com>.
Read this: http://cwiki.apache.org/WICKET/best-practices-and-gotchas.html#BestPracticesandGotchas-WicketServletMapping

There you can read that if you use the servlet mapping, you need to do
it on a subpath, i.e. /app *and* add the asterisk:

<servlet-mapping>
   <servlet-name>MreWicketApplication</servlet-name>
   <url-pattern>/app/*</url-pattern>
 </servlet-mapping>

Martijn

On 9/28/07, Adam A. Koch <ad...@dogtired.org> wrote:
> Here's the URL I'm trying:
> http://localhost/mre/resources/com.*.webapp.wicket.BasePage/mre.css
>
> This (part of) the web.xml that works:
>
>       <filter>
>             <filter-name>MreWicketApplication</filter-name>
>
> <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
>             <init-param>
>               <param-name>applicationClassName</param-name>
>
> <param-value>com.[removed].mre.webapp.wicket.MreWebApplication</param-value>
>             </init-param>
>       </filter>
>
>       <filter-mapping>
>             <filter-name>MreWicketApplication</filter-name>
>             <url-pattern>/*</url-pattern>
>       </filter-mapping>
>
> This is what doesn't work:
>
>   <servlet>
>     <servlet-name>MreWicketApplication</servlet-name>
>     <servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-class>
>     <init-param>
>       <param-name>applicationClassName</param-name>
>       <param-value>com.[removed].mre.webapp.wicket.MreWebApplication</param-value>
>     </init-param>
>     <load-on-startup>1</load-on-startup>
>   </servlet>
>
>   <servlet-mapping>
>     <servlet-name>MreWicketApplication</servlet-name>
>     <url-pattern>/</url-pattern>
>   </servlet-mapping>
>
>
> But even though the url-pattern is "/" everything is under "/mre/". Is
> that the way it's supposed to be?
>
> Thanks,
> Adam
>
> Martijn Dashorst wrote:
> > And perhaps post the contents of your web.xml?
> >
> > Did you map to /app or /app/* ?
> >
> > Martijn
> >
> > On 9/27/07, Adam A. Koch <ad...@dogtired.org> wrote:
> >
> >>  It is mapped to an app and not to the root. The directories I listed are in
> >> the war file, but I tried to access them with http://localhost/myapp/...
> >>
> >>  Kent Tong wrote:
> >>  Adam Koch wrote:
> >>
> >>
> >>  In fact, I couldn't get the JS/CSS in any way when using the servlet. I
> >> tried putting the JS in my app.war in these directories:
> >> / (root)
> >> /classes/com/.../someJS.js
> >> /WEB-INF/classes/com/.../someJS.js (same directory as Class
> >> and html)
> >>
> >>
> >>  Are you mapping the Wicket servlet to root? Try mapping it to something
> >> else
> >> like /app.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0-beta3 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can't access Javascript/CSS when in servletMode

Posted by "Adam A. Koch" <ad...@dogtired.org>.
Here's the URL I'm trying:
http://localhost/mre/resources/com.*.webapp.wicket.BasePage/mre.css

This (part of) the web.xml that works:

      <filter>
            <filter-name>MreWicketApplication</filter-name>

<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
            <init-param>
              <param-name>applicationClassName</param-name>

<param-value>com.[removed].mre.webapp.wicket.MreWebApplication</param-value>
            </init-param>
      </filter>

      <filter-mapping>
            <filter-name>MreWicketApplication</filter-name>
            <url-pattern>/*</url-pattern>
      </filter-mapping>

This is what doesn't work:

  <servlet>
    <servlet-name>MreWicketApplication</servlet-name>
    <servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-class>
    <init-param>
      <param-name>applicationClassName</param-name>
      <param-value>com.[removed].mre.webapp.wicket.MreWebApplication</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>MreWicketApplication</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>


But even though the url-pattern is "/" everything is under "/mre/". Is 
that the way it's supposed to be?

Thanks,
Adam

Martijn Dashorst wrote:
> And perhaps post the contents of your web.xml?
>
> Did you map to /app or /app/* ?
>
> Martijn
>
> On 9/27/07, Adam A. Koch <ad...@dogtired.org> wrote:
>   
>>  It is mapped to an app and not to the root. The directories I listed are in
>> the war file, but I tried to access them with http://localhost/myapp/...
>>
>>  Kent Tong wrote:
>>  Adam Koch wrote:
>>
>>
>>  In fact, I couldn't get the JS/CSS in any way when using the servlet. I
>> tried putting the JS in my app.war in these directories:
>> / (root)
>> /classes/com/.../someJS.js
>> /WEB-INF/classes/com/.../someJS.js (same directory as Class
>> and html)
>>
>>
>>  Are you mapping the Wicket servlet to root? Try mapping it to something
>> else
>> like /app.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>     
>
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can't access Javascript/CSS when in servletMode

Posted by Martijn Dashorst <ma...@gmail.com>.
And perhaps post the contents of your web.xml?

Did you map to /app or /app/* ?

Martijn

On 9/27/07, Adam A. Koch <ad...@dogtired.org> wrote:
>
>  It is mapped to an app and not to the root. The directories I listed are in
> the war file, but I tried to access them with http://localhost/myapp/...
>
>  Kent Tong wrote:
>  Adam Koch wrote:
>
>
>  In fact, I couldn't get the JS/CSS in any way when using the servlet. I
> tried putting the JS in my app.war in these directories:
> / (root)
> /classes/com/.../someJS.js
> /WEB-INF/classes/com/.../someJS.js (same directory as Class
> and html)
>
>
>  Are you mapping the Wicket servlet to root? Try mapping it to something
> else
> like /app.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org


-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0-beta3 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Can't access Javascript/CSS when in servletMode

Posted by Kent Tong <ke...@cpttm.org.mo>.

Adam Koch wrote:
> 
> In fact, I couldn't get the JS/CSS in any way when using the servlet. I
> tried putting the JS in my app.war in these directories:
> / (root)
> /classes/com/.../someJS.js
> /WEB-INF/classes/com/.../someJS.js (same directory as Class and html)
> 

Are you mapping the Wicket servlet to root? Try mapping it to something else
like /app.
-- 
View this message in context: http://www.nabble.com/Can%27t-access-Javascript-CSS-when-in-servletMode-tf4481265.html#a12833582
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org