I am making a JSP program and all it does is show the date:
<html>
<body>
<%
System.out.println( "Evaluating date now" );
java.util.Date date = new java.util.Date();
%>
<p>Hello, the date is
<%
out.println( date );
out.println( "<BR>Your machine's address is " );
out.println(request.getRemoteHost());
%>
</p>
</body>
</html>
On wordpress, all the JSP script shows up as normal text and I don't know why.
Short answer is no. JSP files must be run on an application server such as tomcat. The information here might be helpful.
Related
I am working with silverstripe with first time and I almost create a blog in silverstripe but now I stuck at one place where I need help you guys. If anybody have any idea about it then please help me.
I am trying to add recent posts in my blog. I am using the below code for this
public function latestBlog($num=10) {
/* return BlogEntry::get()->sort('PublishDate','desc')->limit($num); */
echo $blogPosts;
return $blogPosts = BlogPost::get()->filter('ParentID', $this->ID)->limit($num);
}
And in my ss page I am using html like this
<% loop $latestBlog %>
<li>$Title</li>
<% end_loop %>
this gives me titles of the each post but in href I want url too
If my title is "TEST POST" then I want href like "www.mydomain.com/TEST-POST";
Can Anybody have Idea about it?
You can use $Link which will return the relative url. Reference https://docs.silverstripe.org/en/3.2/developer_guides/templates/common_variables/#links
<ul>
<% loop $latestBlog %>
<li>$Title</li>
<% end_loop %>
</ul>
I am new to classic ASP and I am trying to create a Master Page with variable placeholders and fill the information on that page with variables that are worked on a content page.
my master page looks like this:
<html>
<head>
<title>Template Loaded Properly</title>
</head>
<body>
<% call BodyContent %>
<span>Title: <% //place title here %></span>
<span>Content: <% //place content here %></span>
</body>
</html>
and the content page like this:
<!--#include virtual="/templates/TEMPLATE.html" -->
<% sub BodyContent %>
var Title = "This is the title"
var Content = "Here goes some content"
<% end sub %>
Any help will be appreciated.
Once you include the page with the variables, you can treat them as if they were created right then and there (because in a sense they are created right then and there, at least from the server's point of view). You do need to make the variables global in scope [read: dim them outside the sub], unless you want to list all of them when calling your BodyContent sub. (Personally, I don't see the point, but some people are unreasonably allergic to global variables.)
<%
dim Title, Content
sub BodyContent
Title = "This is the title"
Content = "Here goes some content"
end sub
%>
<body>
<% call BodyContent %>
<span>Title: <%=Title%></span>
<span>Content: <%=Content%></span>
</body>
One caveat, though: include files are processed long before the code, so you can't vary what file is included. In other words, don't do this:
<%If x = a Then%>
<!-- #include virtual="/templateA.inc" -->
<%Else%>
<!-- #include virtual="/templateB.inc" -->
<%End If%>
The result of trying something like that is that both templateA and templateB will be included. If you need conditional includes, look into using FileSystemObject to read the content of the appropriate template, and then using Execute to, well, execute it.
This is something that leads me to waste hours and I wish I knew why. I've found lots of examples (not all answered) where forms are not being submitted, it works on a webpage, but not in capybara. things like find/xpath work in the irb.
web page
file box with a upload button, attaching the file works (i'm using poltergeist render to see that file name is attached)
debugging / options tried
find () works e.g. in irb it returns an object: Capybara Element tag=input
if i attempt to "visit '' it returns {"status"=>"fail", "click"=>{"x"=>124, "y"=>283}} [nothing in the log that action called. DEFINITELY works in development environment]
click_on 'Upload' fails: {"status"=>"fail", "click"=>{"x"=>124, "y"=>283}}
find_button('Upload').click: {"status"=>"fail", "click"=>{"x"=>124, "y"=>283}}
find("#upload_bill_button1").trigger("click"): returns "click"
i have tried exec_script of javascript checkBill() . page.execute_script('checkBill()'): returns nil
find(:css, '#upload_bill_button1').click . returns: {"x"=>124, "y"=>282}
nothing in the logs to show the action is being completed
i have
js=>true as its a javascript submit (does a test first, code below).
made sure all ids are unique
capybara::DSL added
system setup
Mac ox X
poltergeist (working for all my other tests)
ruby 1.9.3
phantom 1.9.2
is there further debug to figure out the problem ? other logs i'm missing?
any guidance much appreciated
<div class="row">
<div class="large-10 columns" >
<%=form_tag( "/upload_bill", :method=>:post, :multipart => true, :id => "form_upload1") do -%>
<fieldset>
<legend>Select your bill file</legend>
<%=file_field_tag 'bill', :onclick => "checkBill()" -%>
<div class="large-2 columns" >
<!-- TODO: make the browse button the zurb class type -->
<%- if params[:action].eql?( 'index')%>
<%=submit_tag "Upload", :onclick => "checkBill();return false;", :id => "upload_bill_button1", :class => "button postfix" -%>
<% end %>
</div>
</fieldset>
<% end %>
</div>
</div>
<%- if params[:action].eql?('import_bill')%>
<%=link_to (image_tag "/images/btn-uploadbill.png"), "#", :onclick=>"checkBill();return false;", :id => "upload_bill_button2" -%>
<%=link_to (image_tag "/images/btn-cancel.png"), root_path %>
<%- end %>
<script type="text/javascript">
function checkBill(){
var bill = $("#bill").val();
if(bill.split('.').reverse()[0]=="csv"||bill.split('.').reverse()[0]=="pdf"||bill.split('.').reverse()[0]=="pdftranslatedtxt"){
//success bill supported, data send to app
jQuery('#form_upload1').submit();
}
else if(bill==""){return false; }
else{// return error wrong format of bill alert('We only currently support PDF or CSV file format.')
}
}
</script>
UPDATE
I have the code working on some instance of this page. I have also have one situation where the find/trigger is working (the logs show actions, but the poltergeist:render shows no page update)
so, rspec function is
def new_import_bill(billfile)
path = DATA_TEST+billfile
attach_file("bill", path)
find("#upload_bill_button1").trigger("click")
end
I have debugged the page output e.g.
puts page.html
and there is no difference between the page html that works and the pages that do not work., but in certain situations it refuses to click or the poltergeist.render does not update.
as per this poltergeist bug (https://github.com/jonleighton/poltergeist/issues/209) I have tried removing full:true. No difference
has anyone else come across these inconsistences?
How do I rewrite the following PHP code in Classic ASP?
<head></head>
<body>
<h1>Test</h1>
<section><?php echo include('content/'.$_GET['p'].'.php') ?></section></body>
If the url is http://foo.bar.com/admin.php?p=pages, then content/pages.php is shown.
You can't do this with INCLUDE but you could use Server.Transfer instead, eg.
Server.Transfer "content/" & Request.Form("p") & ".asp"
Never trust what comes from the clientside (browser) as they can try to hack you.
Since it is not likely that "shdyhio3hlkehio.asp" or similar is a proper file, you should limit the options to your actual selection and also have a default file which is a "catch all other requests".
Combine that with Server Side Includes and you have your setup ready.
You should also check if the user actually requested a page -- if "p" is empty then show a default message.
Note the use of LCase in the "Select Case"-line and lowercase values in the Case-lines.
This is due to the face that the string comparison is case-sensitive, meaning "about" (lowercase "a") and "About" (uppercase "A") is not the same.
Eksemple:
<% If Request.QueryString("p") = "" Then %>
no specific page was request, show a default message
<% Else %>
<% Select Case LCase(Request.QueryString("p")) %>
<% Case "content" %><!-- #include file="content.asp" -->
<% Case "about" %><!-- #include file="about.asp" -->
<% Case "contact" %><!-- #include file="contact.asp" -->
<% Case Else %><!-- #include file="404.asp" -->
<% End Select %>
<% End If %>
You can use something like this
<!--#include file="somefile.asp"-->
in your HTML file .
I'm trying to understand ASP but #include doesn't seem to work for some reason. I'm using IIS 7.5 (included with Win 7).
I have two .asp files in .../wwwroot/MyWeb/. I'm trying to #include FiboRecursive.asp in a file called test.asp. Both files work separately if I remove the #include. I have tried both virtual and file includes.
This is test.asp:
<%# language="javascript" %>
<html>
<body>
<p>
<% //Response.Write(Request.ServerVariables("http_user_agent"));%>
</p>
<p>
<%
var remoteAddr = Request.ServerVariables("REMOTE_ADDR");
remoteAddr += "";
if ((remoteAddr.length > 5) && (remoteAddr.substr(0,7)=="140.114") ) {
Response.Write("Hello there Tsingda student!");
}
else {
Response.Write("You're not a Tsingda student!");
}
%>
</p>
<form action="./FiboRecursive.asp" method="post">
<input type="submit" value="Calculate Fibonacci numbers!" />
</form>
<!--#INCLUDE FILE="fiborecursive.asp" -->
</body>
</html>
This is the code in FiboRecursive.asp:
<%# language="javascript" %>
<%
Response.Write("Let's calculate some Fibonacci numbers!");
%>
Edit: Another thing: I always use web developer tools (error console) in Firefox to check for errors in my code, but obviously that doesn't work too well when doing server side stuff. Any way to get some hints as to what's wrong from a console or similar?
You should not have the # command within your include file as this will (in ISS version 5.1 at least) result in the following error:
Error Type:
Active Server Pages, ASP 0141 (0x80004005)
The # command can only be used once within the Active Server Page.