PDA

View Full Version : HTML page error


azkgtr
08-20-2006, 11:25 PM
Hi Guys im new here so i dont know where exactly this thread belongs either in HTML or UNIX since the web server i run is a sun OS cobalt Qube 3. I manage most of my webpages using the VI editor which is great but the problem is i needed to create 3 new webpages and i was lazy so i used editplus and MS frontpage 2003. Now that ive finished with all the formatting and made sure all files where in the correct spelling and uploaded the webpages into the webserver. The new webpages sometimes get a page not found error URL missing. I check the file in the folder and the .html file is listed.

The thing is that it sometimes works on some computers and then i go back 5mins or 10mins later it comes up with the URL is missing...I would say it is a IE problem but it doesnt happen with any of the other links only the three new ones.

I have checked the permissions and changed them to 755 using the CHMOD but it shudnt matter since the original files were a 644 and they still work. I have tried on multiple computers and i have no idea...is it because i created the file in windows and the UNIX system doesnt it like it? can some please give me a direction i can look in.



thanks in advanced

mgolvach
10-13-2007, 04:02 AM
Since you made those pages in windows and then put them on a unix/linux server, you might check to see if Windows, or the transfer, changed them into binary.

If you do a "cat -v" on the files and you see a lot of "^M" characters, that's the issue right there. There's a freeware program for linux/unix called dos2unix that you can run against all of the files to convert them or, since you're into vi, just open the files in vi and do
[esc]:s/[ctl+v][enter]/s///[enter]

the ctl+v followed by the actual enter key should reproduce the ^M non-alpha character correctly. Just typing ^M won't match.

Hope this helped :)

Thanks,

, Mike

epathchina
07-16-2008, 11:33 PM
Many Struts applications can get by with a simple

<html:error/>

tag at the top of a page. If any error messages are present, it's this tag's job to print them all out. To help prettify the output, <html:error> checks for errors.header and errors.footer messages in the application resources. If found, the tag prints these before and after the block of messages. A common setup is:

errors.header=<UL>
errors.footer=</UL>

Struts 1.0 developers can then include <LI> and </LI> tags with the text of each message to used this way. In Struts 1.1, the situation improves with the addition of the errors.prefix and errors.suffix messages. Just as the header and footer print before and after the block of messages, the prefix and suffix print before the individual messages. So to print a simple list of any message that might arise, you can just include

errors.header=<UL>
errors.footer</UL>
errors.prefix=<LI>
errors.suffix=</LI>

in your application resources, and the (Struts 1.1) <html:error> tag will take care of the rest.

Though, many purists would complain that HTML markup has no place in a message resources file. And they would right. Even with the Struts 1.1 prefix and suffix feature, you may still need to use different markup different pages.

For Struts 1.0 applications, the Struts Validation extension (see the Struts Resource page) offers a useful alternative to the standard <html:error/> tag. You can use these tags whether you are using the rest of the validator package or not. Instead of providing one omnibus tag, the validator approach is to use an iterator to expose each message, and then leave it up to the page to provide whatever other formatting is necessary. Here's an example:

<validator:errorsExist>
<UL>
<validator:errors id="error">
<LI><bean:write name="error"/></LI>
</validator:errors>
</UL>
</validator:errorsExist>

In Struts 1.1, these tags were adopted into the core taglibs. Here's the same example using the Struts 1.1 rendition.

<logic:messagesPresent>
<UL>
<html:messages id="error">
<LI><bean:write name="error"/></LI>
</html:messages>
</UL>
</logic:messagesPresent>

This is all great if you just want to print your messages as a batch. But many messages are related to data-entry validation and involve a specific field. Many page designs expect a message concerning a field to printed next to a field.

Not a problem. When the error message is queued, you can specify a "property" to go with it. If you don't specify a property (using any of the tags we described), then all the messages print. If you do specify a property, then only the messages queued for that property print.

The default code for queuing an error message is:

errors.add(
ActionErrors.GLOBAL_ERROR,
new ActionError("error.username.required")
);

To specify that this message is for the "username" property, we would code this instead:

errors.add(
"username", new ActionError("error.username.required"));

If we specify a property, we can use the <html:errors/> tag (or any of the alternatives) like this:

<P>Username: <html:text property="username"/></P>
<P>Password: <html:password property="password"/></P>

The "username" errors print next to the username field, and any "password" errors print next to the password field.

But what if you need to print both specific and general errors?

Again, no problem. You can also specify the "generic" property just like you did in the Java code. First, at the top of your JavaServer Page import the Action and ActionErrors package so you can reference the appropriate constants:

<%@ page import="org.apache.struts.action.Action" %>
<%@ page import="org.apache.struts.action.ActionErrors" %>

Then in the tags, use a runtime expression to specify the constants:

<logic:present name="<%=Action.ERROR_KEY%>">
<P><html:errors property="<%=ActionErrors.GLOBAL_ERROR%>"/></P>
</logic:present>

Viola! Specific messages print out in specific places, and any "general" errors can still print out in a place of their own.

Of course, you don't have to settle for any of these standard tags. If these variations still don't meet your specific needs, take a peek at the source code and cobble up your own! The framework provides the queue, but how it prints is up to you.
Portable Media Players (http://www.epathchina.com/portable-media-players-c-28.html)

jackspar
09-30-2008, 09:49 AM
Set your custom error pages using htaccess. Create a page just like any other, with a message like 'sorry, the page you are looking for cannot be found' (404) or 'there is a problem running this script' (500).

_________
jackspar.