node.js - Need node with express to switch between static and dynamic content -
question: rewrite after learning more revising question.
below have form @ "/form.html" (currently doing instead of post; don't think it's issue )
the form submits "/transfer" runs java code. need java code 'success' or 'errors' user. have tried both
response.send('success') and
response.writehead(200, { 'content-type': 'text/html' }); res.end('success', 'utf-8'); neither work
var express = require('express'); var routes = require('routes'); var log4js = require('log4js'); // npm install log4js var fs = require('fs'); var http = require('http'); var java = require("java"); var path = require("path"); var upload = require("blueimp-file-upload-node"); var app = express(); app.get('/form', function(req, res) { fs.readfile('./form.html', function(error, content) { if (error) { console.log(error); res.writehead(200, { 'content-type': 'text/html' }); res.end('oops', 'utf-8'); } else { res.writehead(200, { 'content-type': 'text/html' }); res.end(content, 'utf-8'); } }); }); app.get('/transfer', function(request, response) { java.classpath.push("../csv2rdf"); java.classpath.push("../lib/commons-io-2.4.jar"); java.classpath.push("../lib/log4j-1.2.16.jar"); java.classpath.push("../lib/slf4j-api-1.7.5.jar"); ... var result = ""; seek { var appx = java.callstaticmethodsync("com.appx.converter.cv2appx.runner", "nodejs", request.query.user, request.query.pass, request.query.file, request.query.auth); result = request.query.user.concat(":", request.query.file); console.log(result); ** how send success in response ** } grab (ex) { result = result.concat(" ", request.query.user, ":", request.query.file); console.log(result); ** how send errors in response ** } }); app.listen(3000); node.js express
No comments:
Post a Comment