vPath cutting off path location name?

Z

zz12

Hello. We have a SearchResults.asp page that returns a list of asp pages
that are associated with the user's search parameters that they type in in a
search page called something like Search.asp. We noticed that the last line
in the following rs("vpath") value lists the path up until the first blank
of either a folder or file name and cuts off the rest of the path's text
name. Does anyone know how to have the vpath list the entire path name even
including spaces if there are any?

<%
Dim sSearchString
Dim oQuery

sSearchString = Request.Form("query")

Const SEARCH_CATALOG = "web" 'remember to change this

Set oQuery = Server.CreateObject("IXSSO.Query")
oQuery.Catalog = SEARCH_CATALOG
oQuery.Query = "@all " & sSearchString & " AND NOT #path *_* AND NOT #path
*downloads* AND NOT #path *images* AND NOT #filename *.class AND NOT
#filename *.asa AND NOT #filename *.css AND NOT #filename *postinfo.html"
oQuery.MaxRecords = 200
oQuery.SortBy = "rank[d]"
oQuery.Columns = "DocAuthor, vpath, doctitle, FileName, Path, Write, Size,
Rank, Create, Characterization, DocCategory"
Set rs = oQuery.CreateRecordSet("nonsequential")

Response.write "<a href=" & rs("vpath") & "> <font color='#49698D' size='2'
style='arial'><b>" & rs("doctitle") & "</b></font></a><br>"
%>

Thanks in advance.
 
D

Daniel Crichton

zz12 wrote on Wed, 13 Jun 2007 16:41:08 -0700:
Hello. We have a SearchResults.asp page that returns a list of asp pages
that are associated with the user's search parameters that they type in in
a search page called something like Search.asp. We noticed that the last
line in the following rs("vpath") value lists the path up until the first
blank of either a folder or file name and cuts off the rest of the path's
text name. Does anyone know how to have the vpath list the entire path
name even including spaces if there are any?

<%
Dim sSearchString
Dim oQuery

sSearchString = Request.Form("query")

Const SEARCH_CATALOG = "web" 'remember to change this

Set oQuery = Server.CreateObject("IXSSO.Query")
oQuery.Catalog = SEARCH_CATALOG
oQuery.Query = "@all " & sSearchString & " AND NOT #path *_* AND NOT #path
*downloads* AND NOT #path *images* AND NOT #filename *.class AND NOT
#filename *.asa AND NOT #filename *.css AND NOT #filename *postinfo.html"
oQuery.MaxRecords = 200
oQuery.SortBy = "rank[d]"
oQuery.Columns = "DocAuthor, vpath, doctitle, FileName, Path, Write, Size,
Rank, Create, Characterization, DocCategory"
Set rs = oQuery.CreateRecordSet("nonsequential")

Response.write "<a href=" & rs("vpath") & "> <font color='#49698D'
size='2' style='arial'><b>" & rs("doctitle") & "</b></font></a><br>"
%>

You need to put quotes around the path, and I'd recommend URL encoding them
too. For completeness I'd also recommend HTML encoding doctitle just in case
there are any characters that might cause problems (however, if you know
this is already in HTML format you can remove the Server.HTMLEncode function
call)

Response.write "<a href=""" & Server.URLEncode(rs("vpath")) & """> <font
color='#49698D'
size='2' style='arial'><b>" & Server.HTMLEncode(rs("doctitle")) &
"</b></font></a><br>"

Notice the "" before and after the path value, this writes a " at those
positions

That should do it. The reason the path was being cut at the space is because
without the href value being quote the browser has to use spaces as the
attribute delimiters, eg.

<a href=my path>

the href value becomes "my", because "path" could be another attribute name.
If you had

<a href="my path">

then the browser will know that "my path" is the entire path. However,
spaces in URLs are not allowed, so you do this:

<a href="my+path">

and everthing works properly. Server.URLEncode will do all the work of
ensuring that the vpath value is correctly presented for URL use, replacing
all non-legal chars with URL entities.

Dan
 
Z

zz12

That fixed it. You are awesome. Thanks a bunch Daniel. Much appreciated.

Take cares :)


Daniel Crichton said:
zz12 wrote on Wed, 13 Jun 2007 16:41:08 -0700:
Hello. We have a SearchResults.asp page that returns a list of asp pages
that are associated with the user's search parameters that they type in
in
a search page called something like Search.asp. We noticed that the last
line in the following rs("vpath") value lists the path up until the first
blank of either a folder or file name and cuts off the rest of the path's
text name. Does anyone know how to have the vpath list the entire path
name even including spaces if there are any?

<%
Dim sSearchString
Dim oQuery

sSearchString = Request.Form("query")

Const SEARCH_CATALOG = "web" 'remember to change this

Set oQuery = Server.CreateObject("IXSSO.Query")
oQuery.Catalog = SEARCH_CATALOG
oQuery.Query = "@all " & sSearchString & " AND NOT #path *_* AND NOT
#path
*downloads* AND NOT #path *images* AND NOT #filename *.class AND NOT
#filename *.asa AND NOT #filename *.css AND NOT #filename *postinfo.html"
oQuery.MaxRecords = 200
oQuery.SortBy = "rank[d]"
oQuery.Columns = "DocAuthor, vpath, doctitle, FileName, Path, Write,
Size,
Rank, Create, Characterization, DocCategory"
Set rs = oQuery.CreateRecordSet("nonsequential")

Response.write "<a href=" & rs("vpath") & "> <font color='#49698D'
size='2' style='arial'><b>" & rs("doctitle") & "</b></font></a><br>"
%>

You need to put quotes around the path, and I'd recommend URL encoding
them too. For completeness I'd also recommend HTML encoding doctitle just
in case there are any characters that might cause problems (however, if
you know this is already in HTML format you can remove the
Server.HTMLEncode function call)

Response.write "<a href=""" & Server.URLEncode(rs("vpath")) & """> <font
color='#49698D'
size='2' style='arial'><b>" & Server.HTMLEncode(rs("doctitle")) &
"</b></font></a><br>"

Notice the "" before and after the path value, this writes a " at those
positions

That should do it. The reason the path was being cut at the space is
because without the href value being quote the browser has to use spaces
as the attribute delimiters, eg.

<a href=my path>

the href value becomes "my", because "path" could be another attribute
name. If you had

<a href="my path">

then the browser will know that "my path" is the entire path. However,
spaces in URLs are not allowed, so you do this:

<a href="my+path">

and everthing works properly. Server.URLEncode will do all the work of
ensuring that the vpath value is correctly presented for URL use,
replacing all non-legal chars with URL entities.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top