File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How to run Struts 2 offline Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to run Struts 2 offline" Watch "How to run Struts 2 offline" New topic
Author

How to run Struts 2 offline

Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi All,
I'm new to Struts 2 and would like to run it without being connected to the internet all the while(as I think ,every time i try to run my app , the struts.xml references--
"http://struts.apache.org/dtds/struts-2.0.dtd">

)
IS there any way I could perform my development offline . I'm using the Eclipse IDE , if that's of any help.
Thanks.


Learning and Learning!-- Java all the way!
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Bounce!
Rupesh Mhatre
Ranch Hand

Joined: Apr 29, 2011
Posts: 35

I was wondering why would it not be running offline
Alex Barnes
Greenhorn

Joined: May 03, 2011
Posts: 5

Look in Eclipse under Window > Preferences > General > Network Connections > Cache

Is there an entry for this DTD?
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Alex Barnes wrote:Look in Eclipse under Window > Preferences > General > Network Connections > Cache

Is there an entry for this DTD?

Yes, there is an entry . How should i go about modifying it ,to be able to work offline??
Alex Barnes
Greenhorn

Joined: May 03, 2011
Posts: 5

I would have guessed that the presence of this cache entry means that you wouldn't need to access the internet to get the DTD.
Alex Barnes
Greenhorn

Joined: May 03, 2011
Posts: 5

Can you try changing your struts.xml to this:

<!DOCTYPE struts SYSTEM "struts-2.0.dtd"> rather than

<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

as discussed here. This will ensure that the DTD is loaded from the struts2-core jar on the classpath rather than from a remote URL.
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Thanks Alex, it seems to be working now , without making the changes , I tried after momentarily disconnecting from the internet .Thanks for replying !
Rupesh Mhatre
Ranch Hand

Joined: Apr 29, 2011
Posts: 35

nice stuff Alex
ravidream Thapa
Greenhorn

Joined: Dec 17, 2014
Posts: 1
In your struts.xml write DTD configration this way.



Step 1.



<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"../WEB-INF/struts-2.0.dtd">



Step 2.



Put struts dtd file in WEB-INF directory
struts-2.0.dtd

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* $Id: struts-2.0.dtd 651946 2008-04-27 13:41:38Z apetrelli $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
-->
<!-- START SNIPPET: strutsDtd -->

<!--
Struts configuration DTD.
Use the following DOCTYPE

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
-->

<!ELEMENT struts (package|include|bean|constant)*>

<!ELEMENT package (result-types?, interceptors?, default-interceptor-ref?, default-action-ref?, default-class-ref?, global-results?, global-exception-mappings?, action*)>
<!ATTLIST package
name CDATA #REQUIRED
extends CDATA #IMPLIED
namespace CDATA #IMPLIED
abstract CDATA #IMPLIED
externalReferenceResolver NMTOKEN #IMPLIED
>

<!ELEMENT result-types (result-type+)>

<!ELEMENT result-type (param*)>
<!ATTLIST result-type
name CDATA #REQUIRED
class CDATA #REQUIRED
default (true|false) "false"
>

<!ELEMENT interceptors (interceptor|interceptor-stack)+>

<!ELEMENT interceptor (param*)>
<!ATTLIST interceptor
name CDATA #REQUIRED
class CDATA #REQUIRED
>

<!ELEMENT interceptor-stack (interceptor-ref*)>
<!ATTLIST interceptor-stack
name CDATA #REQUIRED
>

<!ELEMENT interceptor-ref (param*)>
<!ATTLIST interceptor-ref
name CDATA #REQUIRED
>

<!ELEMENT default-interceptor-ref (#PCDATA)>
<!ATTLIST default-interceptor-ref
name CDATA #REQUIRED
>

<!ELEMENT default-action-ref (#PCDATA)>
<!ATTLIST default-action-ref
name CDATA #REQUIRED
>

<!ELEMENT default-class-ref (#PCDATA)>
<!ATTLIST default-class-ref
class CDATA #REQUIRED
>

<!ELEMENT global-results (result+)>

<!ELEMENT global-exception-mappings (exception-mapping+)>

<!ELEMENT action (param|result|interceptor-ref|exception-mapping)*>
<!ATTLIST action
name CDATA #REQUIRED
class CDATA #IMPLIED
method CDATA #IMPLIED
converter CDATA #IMPLIED
>

<!ELEMENT param (#PCDATA)>
<!ATTLIST param
name CDATA #REQUIRED
>

<!ELEMENT result (#PCDATA|param)*>
<!ATTLIST result
name CDATA #IMPLIED
type CDATA #IMPLIED
>

<!ELEMENT exception-mapping (#PCDATA|param)*>
<!ATTLIST exception-mapping
name CDATA #IMPLIED
exception CDATA #REQUIRED
result CDATA #REQUIRED
>

<!ELEMENT include (#PCDATA)>
<!ATTLIST include
file CDATA #REQUIRED
>

<!ELEMENT bean (#PCDATA)>
<!ATTLIST bean
type CDATA #IMPLIED
name CDATA #IMPLIED
class CDATA #REQUIRED
scope CDATA #IMPLIED
static CDATA #IMPLIED
optional CDATA #IMPLIED
>

<!ELEMENT constant (#PCDATA)>
<!ATTLIST constant
name CDATA #REQUIRED
value CDATA #REQUIRED
>

<!-- END SNIPPET: strutsDtd -->
////////////////////////////////////////////////////////////////////////


Step 3. Take care of the version of dependencies that all should be on same version.


[struts.png]

Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8994
    
    9

Welcome to the JavaRanch, ravidream.
You should be aware that this question was answered in 2011, so hopefully the posters are no longer waiting for an answer. Also, there are several updates to the DTD you posted, so if one is using features introduced since Struts 2.0, they would get errors. DTD's are located in the src\core\src\main\resources\ directory of the Struts distribution. This would be a more reliable source than copying and pasting from here.
Personally, I would not make changes to the Struts distribution unless absolutely necessary (i.e. the application is to be deployed inside a subnet that is isolated from the internet in general).


[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to run Struts 2 offline